Git Autocomplete

To enable git autocomplete in terminal:

cp /opt/local/share/doc/git-core/contrib/completion/git-completion.bash ~/

Then, add the following to .bashrc or .bash_profile

source ~/

If you do aliases for your commands, you will need to add those as well.

complete -o default -o nospace -F _git_branch gb
complete -o default -o nospace -F _git_checkout gco
alias gst='git status '
alias gc='git commit '
alias gca='git commit -a '
alias ga='git add '
alias gco='git checkout '
alias gb='git branch '
alias gm='git merge '

NOTE: If you get the following error:

bash: __git_ps1: command not found

That means there is a version mismatch, git refactored __git_ps1 to another file.

curl -o ~/
source ~/

function parse_git_dirty { if [[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]]; then echo "" elif [[ $(git status 2> /dev/null | tail -n1) != "no changes added to commit (use \"git add\" and/or \"git commit -a\")" ]]; then echo "*" elif [[(( $(git status 2> /dev/null | grep 'Your branch is ahead of' | wc -l) != 0 ))]]; then echo "+" fi }