12

Here is my setup:

brew install git bash-completion
Warning: git-2.1.3 already installed
Warning: bash-completion-1.3 already installed

In .bash_profile:

if [ -f $(brew --prefix)/etc/bash_completion ]; then
    . $(brew --prefix)/etc/bash_completion
fi

But I still don't have autocompletion for git commands. (I used macports before, but completely removed it because I couldn't get git commands to autocomplete no matter what I tried.)

I am on OSX 10.10

10

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.

3

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
  • 1
    Did this wget https://raw.github.com/git/git/master/contrib/completion/git-completion.bash && source git-completion.bash, no luck yet. – qed Nov 4 '14 at 21:00
  • @qed, that + answer's .bash_profile worked for me. – Maragues Dec 8 '14 at 18:09
  • Even . ~/.git-completion.bash directly in the shell does not work. No error message either. – qed Apr 4 '16 at 12:08
1

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.

  • I already have that, but it still doesn't work. – qed Apr 4 '16 at 12:05
  • Along with the other answers, doing this as well worked for me. Thanks! – Vandesh Nov 29 '17 at 15:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .