Sometimes git projects can have a lot of different branches, and you might need to frequently check out different branches. It can be tedious to write out the entire branch name every time (especially if you tend to have longer branch names). Luckily, there's a fix for that: git auto-complete.
You'll need to make the file git-completion.bash permanently available to your .bash_profile file. The easiest way to do that is to copy the file into your home directory as .git-completion. Here are the three easiest methods to copy that file into place - choose the one method that you're most comfortable with...
curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion
Install wget, if you don't already have it:
brew install wget
Use this command to create the .git-completion file:
wget https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -O ~/.git-completion
Go to the URL https://raw.github.com/git/git/master/contrib/completion/git-completion.bash, and save the file as .git-completion in your home directory.
With that file in place, you'll need to edit your ~/.bash_profile file with your editor of choice. Just add this line to the end of the file:
source ~/.git-completion
After saving the .bash_profile changes, you will need to quit Terminal then re-open it for the changes to take place. Alternatively, you can run this command to force the changes without restarting Terminal:
source ~/.profile
Now branch names are auto-completed in Terminal! If you have a branch named "some-other-new-feature" (and let's assume for this example that you have no other branches that start with the letter s) then you can check out the branch with git chec<tab> s<tab>, which will auto-complete both of the <tab> keystrokes out to git checkout some-other-new-feature.
bash cURL git homebrew mac terminal wget
16 Oct 2009 Holyoke's Center City Vision Plan
20 Jan 2012 Using a custom version of Git on Mac OS X Lion
31 Jan 2012 Make a GitHub Project Page that's an exact mirror of your Master branch
07 Oct 2009 Names And Places
16 Jul 2012 How to Use Console to view the log files for your Rails App