Git Auto-completion is quite useful to auto-complete git commands on the terminal. Here is how to enable this nice script.
1) Using curl, download the script to your home directory:
curl -OL https://github.com/git/git/raw/master/contrib/completion/git-completion.bash
2) Make it a dot file:
mv ~/git-completion.bash .git-completion.bash
3) Add this little code snippet to your ~/.bash_profile file:
if [ -f ~/.git-completion.bash ]; then
source ~/.git-completion.bash
fi
This basically checks if .git-completion.bash exists or not, and if it does, it loads it.4) Quit the terminal window and open it again for the changes to take effect. Alternatively, run
source ~/.bash_profile.
5) To see if this worked correctly, type ‘git h’ and hit tab. It should expand it to ‘git help’.
Reference: Lynda.com Git Tutorials.