1. curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
2. 在~/.bash_profile中加如下内容:
if [ -f ~/.git-completion.bash ]; then . ~/.git-completion.bash fi
3. If this doesn't work off the bat, you may need to run chmod -X ~/.git-completion.bash
to give the script permission to run.
4. Restart terminal
详细见:http://apple.stackexchange.com/questions/55875/git-auto-complete-for-branches-at-the-command-line