Git autocompletion is not working with homebrew

Solution 1:

For Yosemite, after I upgraded to git 2.1.3 with homebrew, this worked in my .profile file (.bash_profile or similar would work, too):

# git tab completion (homebrew)
if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
    . `brew --prefix`/etc/bash_completion.d/git-completion.bash
fi

I used to have git-prompt.sh there, but changing it to git-completion.bash worked for me. ymmv.

Solution 2:

Try download directly in your home directory:

curl -O https://raw.github.com/git/git/master/contrib/completion/git-completion.bash
mv git-completion.bash .git-completion.bash

Then in your .bash_profile add the following:

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

Solution 3:

On my system (10.10.5), I fixed this by creating a symlink in /usr/local/etc/bash_completion.d/ to the bash_completion.d/git-completion.bash in the GIT directory. In my case:

cd /usr/local/etc/bash_completion.d
ln -s ../../Cellar/git/2.7.2/etc/bash_completion.d/git-completion.bash git-completion.bash

be sure to checkout your installed version of git and replace 2.7.2 with your version.