When working in GIT based software projects that have a broad range of GIT branches the need for autocompletion of these branch names and GIT commands in general in the shell is one of the first tasks you want to setup for your developers (and yourself ;). After all it’s all about removing impediments to get highly motivated developers who produce high quality code in return, isn’t it?
Setup git-completion.bash in your shell to enable command and branch name autocompletion
By default GIT ships a file called git-completion.bash (at least on Linux, Mac and most probably other major platforms as well) that when setup in your shell will autocomplete commands and branch names, nice right! This file actually represent a comprehensive ruleset that will autocomplete all kinds of GIT commands, try it out you will be amazed.
Normally you find this file in contrib/complete/git-completion.bash but you can also download it from github.
All you have to do to enable branch name and command autocompletion for GIT is to add a source reference to git-completion.bash in your shell’s profile (~/.bashrc or ~/.profile). So open up your shell’s profile (I’ve chosen ~/.profile here)
and add a source call to the git-completion.bash file
In case there’s no immediate effect do a manual source call on your shell profile file:
$ source ~/.profile
This should be all to enable branch name autocompletion for GIT. Enjoy your developers’ and your new productivity!