Shortcuts for git commands

前端 未结 6 1115
天命终不由人
天命终不由人 2021-02-05 04:35

I would like to use shortcuts or aliases for git commands.

git diff
git status
git push 
git pull
git stash
git branch -a

How do I create shor

6条回答
  •  旧巷少年郎
    2021-02-05 04:58

    More than one way to do this. Explained below with examples:

    [1] Using the "alias" option provided by the git itself.

    Example: git config --global alias.co checkout

    Usage hence: git co

    This is equivalent to making entries manually in the '~/.gitconfig' (this path since, --global is used, otherwise the .gitconfig file of the project, in which you attempting to set will be used).

    [alias]
      co = checkout
    

    Therefore, manually making entry to the file, as specified can also be another way of setting your aliases.

    for more Info

    [2] Using .bash_profile/.bashrc.

    Edit your ~/.bash_profile or ~/.bashrc, as below:

    Example: alias go='git checkout'

    Usage hence: go

    (Do not forget to 'source ~/.bash_profile' or 'source ~/.bashrc' after the changes to the file, based on your case).

    for more Info

    So, if you clearly see, the second way is to further put the shorthand/aliases to the git-command usage (for your profile).

    Also, the aliases meant for ease of usability, hence what you prefer/at ease, is what you can add (like: i can say probably, Giraffe = git checkout, if that is my ease).

提交回复
热议问题