Reputation: 141110
Github has the following recommendation for global git configuration ~/.gitconfig
:
[alias] # Is this [-] only a comment in .gitconfig?
gb = git branch
gba = git branch -a
gc = git commit -v
gd = git diff | mate
gl = git pull
gp = git push
gst = git status
The above commands worked in my old Git. However, they do not work now for some unknown reason.
The problem seems not to be in the commands. It is perhaps in another git related file which controls which file affects aliases.
How can you get the aliases to work?
Upvotes: 10
Views: 11791
Reputation: 61
In my case, i navigated to .zsh folder and cloned this repo as git clone https://github.com/mdumitru/git-aliases.git
, then source ~/.zshrc
and is worked.
Upvotes: 0
Reputation: 3438
The first thing to be aware of is that the git aliases only apply when you are calling git, so an alias of st = status
will take effect when you run:
$ git st
If you want to be able to do:
$ gst
To run git status
you would need to set up an alias for bash (or whatever shell you use).
Well, for aliases which are simply shorter versions of git commands (like st
for status
), you do not need to add the git
prefix to it. Additionally, if you want to execute a shell command rather than a git sub-command, you must prefix the alias definition with an exclamation point, as specified in git-config(1)
. My alias section of my ~/.gitconfig
looks like this:
[alias]
st = status
ci = commit -s
br = branch
co = checkout
vis = !gitk --all &
And then I can run:
$ git st # Runs "git status"
$ git ci # Runs "git commit -s"
$ git vis # runs "gitk --all &"
And so on.
Upvotes: 22
Reputation: 1323343
I believe what GitHub is referring to is system aliases, not '.gitconfig' aliases.
In other terms, you would need to type, like illustrated here, the following Unix command to make those 'aliases' work:
alias g=’git’
alias gb=’git branch’
alias gba=’git branch -a’
alias gc=’git commit -v’
alias gca=’git commit -v -a’
alias gd=’git diff | mate’
alias gl=’git pull’
alias gp=’git push’
Upvotes: 11