Β· 1 min read

Autocomplete branch names on the command line

Trying to get over the force of habit that is using tab to auto-complete things on Mac. Well, it doesn’t work for git out of the box but here is a way to get it working on the command line. You can use this script as part of your bash_profile in order to be able to auto-complete long branch names by pressing tab.

First, download the script to your home folder:

curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash

Next, you need to edit your ~/.bash_profile and add the following:

if [ -f ~/.git-completion.bash ]; then
  . ~/.git-completion.bash
fi

Source: http://apple.stackexchange.com/questions/55875/how-can-i-get-git-to-autocomplete-e-g-branches-at-the-command-line/55886#55886