Git autocomplete in Mac OS X

I always liked that my Git installations on Unix and Linux comes with the contrib/complete/git-completion.bash script activated or easily activated. But its harder if you use the pre-built binaries for Mac OS X.

To get autocompletion to work on Mac OS X when installing the pre-built binaries do this.
UPDATE: 2013-08-07New URLs to Github. Thanks to fabb.

1. Download the completion script from Github

curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -OL

2. Add the following to your ~/.profile or ~/.bash_profile

source ~/git-completion.bash
alias gco='git co'
alias gci='git ci'
alias grb='git rb'

3. Add the following to your ~/.gitconfig

[alias]
co = checkout
ci = commit
rb = rebase

Restart Terminal and start Tabbin’!

More Git tips that I found usefull can be found on Tim Dysinger’s blog http://dysinger.net/2007/12/30/installing-git-on-mac-os-x-105-leopard

40 Responses to “Git autocomplete in Mac OS X”

Leave a Reply