Git aliases – a step by step recipe (using Textmate)

Want to set up aliases that make Git easier to use? Have Textmate? Awesome.

Step 1 – launch Terminal (Applications/Utilities/Terminal). When the prompt loads, enter this command:

cd $home

It just returns you to the home folder in the event you aren’t already.

Step 2 – enter this command:

mate .bash_profile

This opens your .bash_profile document in Textmate.

Step 3 – Once that document open, paste in the following chunk:

alias gs='git status '
alias ga='git add '
alias gb='git branch '
alias gc='git commit'
alias gca='git commit -a'
alias gd='git diff'
alias go='git checkout '
alias gk='gitk --all&'
alias gx='gitx --all'
alias gp='git pull'
alias push='git push'
alias gr='git rebase '
alias gm='git merge '

alias got='git ' alias get='git '

Step 4 – Save and close the document. Back in the terminal, start a new tab, and the aliases should work. Now, instead of having to enter

git commit -a

You can simply enter

gca

Faster, no? Please note, this was based on information I found over at Git Immersion, but I’ve distilled it for Mac OS X users, and added a few more aliases of my own.

  • Eric

    This only works if you are using bash as your shell, but you can also enter these into ~/.bash_aliases as well as the rc file for any shell (.cshrc for csh, .tcshrc for tcsh, etc.) among other interesting places to hide these things.

  • Pingback: Useful Bash Aliases for GIT | Geraint Palmer()