How do I avoid typing “git” at the begining of every Git command?

后端 未结 15 1026
醉酒成梦
醉酒成梦 2021-01-29 22:31

I\'m wondering if there\'s a way to avoid having to type the word git at the beginning of every Git command.

It would be nice if there was a way to use the

15条回答
  •  死守一世寂寞
    2021-01-29 22:59

    Another approach that will work with any commands: use Ctrl+R (reverse-i-search).

    The reverse-i-search allows you to search your command history. Repeat Ctrl+R after pressing your search string to repeat search further back with the same string.

    You only need to type a command once, then you can recall that command from any substrings of the command. In most cases, you can recall entire very long commands and their various variants with just two to three well-placed search letters. No preconfigurations needed other than using your shell normally and it is self-adaptive to how you used the shell, simply type the full command once and the commands would be automatically added to your command history.

    • git commit --amend: am
    • git pull: pu
    • git rebase --rebase-merges -i --onto origin/develop origin/develop feature/blue-header: blu
    • git rebase --abort: ab
    • git rebase --continue: con
    • docker-compose stop && git pull && make && docker-compose up -d: up
    • etc

    Moreover, Ctrl-R works not on just bash, but a lot of programs that uses readline library (and there are a lot of them), like Python shell, IPython, mysql shell, psql shell, irb (ruby), etc.

提交回复
热议问题