Autocomplete Git branch names in Terminal
No more typing long winded branch names
I should have looked earlier. I knew it was a time thief. I should have looked earlier.
At work we use the format issue-123-short-description for our Git branch names. The number links through to our issue tracker and may also start story-123 where appropriate. Some developers in the office use GUIs to manage their Git stuff so didn’t feel the pain and certainly didn’t limit themselves when choosing ‘short’ branch-name-with-clever-description-texts.
But I finally did the digging and found the solution to the problem.
Open up a Terminal window
>curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
then you need to edit your .bash_profile file
>nano ~/.bash_profile
to add the following to the bottom and save
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
fi
and finally reload .bash_profile with
>source ~/.bash_profile
and you are done! Branch names should now be just a tab away.
Original solutions in part from http://code-worrier.com/blog/autocomplete-git/