First put the following script somewhere, like ~/git_completion.sh
and chmod +x
it.
Then add this line to your ~/.bash_profile
:
. ~/git_completion.sh
Finally, if you want to pretty up your prompt as above, then add this:
export PS1=’\h:\W \[\e[1;32m\]$(__git_ps1 “[%s]”)\[\e[0m\] > ‘
You can also install git from http://code.google.com/p/git-osx-installer/ (Thanks Jon)
Or on ubuntu install a package called “git-completion” (Thanks Juan)