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

后端 未结 15 770
醉酒成梦
醉酒成梦 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:58

    Use a brackets editor, it's easy to use your code and git commands, it also has many features.

    To the top right corner the second binocular icon is used to install extensions.

    Search extension brackets git like the above image and install it.

    Again to the top right corner there will show the fourth icon, so just click and see the changes like the above image.

    If you want to install brackets, use the following commands:

    sudo add-apt-repository ppa:webupd8team/brackets
    sudo apt-get update
    sudo apt-get install brackets
    

    For more information, you can read: How to Install Brackets Code Editor in Ubuntu and Linux Mint on Ubuntupit.

    0 讨论(0)
  • 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: <Ctrl+R>am
    • git pull: <Ctrl+R>pu
    • git rebase --rebase-merges -i --onto origin/develop origin/develop feature/blue-header: <Ctrl+R>blu
    • git rebase --abort: <Ctrl-R>ab
    • git rebase --continue: <Ctrl-R>con
    • docker-compose stop && git pull && make && docker-compose up -d: <Ctrl-R>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.

    0 讨论(0)
  • 2021-01-29 23:04

    When I used Windows 7 with Conemu, I added the following to my dev environment startup script:

    doskey g=git $*
    

    With this, I could just use the g command instead of typing git. Last I tried with Windows 10 and Conemu, it did not work, there is a bug, I think, but it's worth a try.

    0 讨论(0)
提交回复
热议问题