As others have said the appropriate way to add git aliases is in your global
.gitconfig file either by editing
~/.gitconfig or by using the
git config --global alias.<alias> <git-command> command
Below is a copy of the alias section of my
st = status
ci = commit
co = checkout
br = branch
unstage = reset HEAD --
last = log -1 HEAD
Also, if you're using bash, I would recommend setting up bash completion by copying
git-completion.bash to your home directory and sourcing it from your
~/.bashrc. (I believe I learned about this from the Pro Git online book.) On Mac OS X, I accomplished this with the following commands:
# Copy git-completion.bash to home directory
cp usr/local/git/contrib/completion/git-completion.bash ~/
# Add the following lines to ~/.bashrc
if [ -x /usr/local/git/bin/git ]; then
Note: The bash completion will work not only for the standard git commands but also for your git aliases.
Finally, to really cut down on the keystrokes, I added the following to my
~/.bash_aliases file, which is sourced from
alias gst='git status'
alias gl='git pull'
alias gp='git push'
alias gd='git diff | mate'
alias gau='git add --update'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gb='git branch'
alias gba='git branch -a'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gcot='git checkout -t'
alias gcotb='git checkout --track -b'
alias glog='git log'
alias glogp='git log --pretty=format:"%h %s" --graph'