Homebrew’s `git` not using completion

When using OSX’s git, after I modify a file I can simply do git commit <tab>, and that’ll auto complete the file’s name to the one that was modified. However, if I install a newer version of git from homebrew and I use it, that feature no longer works (meaning I press <tab> and it just “asks” me what file I want to do it on, even including the ones that have no changes).

Can anyone shed some light as to why, and how to solve that? I’d prefer using homebrew’s git, since it’s more up-to-date.

My shell is zsh, and Neither installing bash-completion or zsh-completions worked (even after following homebrew’s post-install instructions).

Also, after installing git with homebrew it says

Bash completion has been installed to: /usr/local/etc/bash_completion.d
zsh completion has been installed to: /usr/local/share/zsh/site-functions

So shouldn’t I be able to use one of those?

  • How to disable git aware zsh theme on folders that dont have a .git/
  • To get a prompt which indicates Git-branch in Zsh
  • Translate parse_git_branch function to zsh from bash (for prompt)
  • To get Git-prompt work in Zsh without a bug in a function
  • in zsh, how do I do a conditional on the exit status of a program?
  • npm install - git problems
  • How can I get 'git status' to always use short format?
  • How to show git status info on the right side of the terminal?
  • 10 Solutions collect form web for “Homebrew’s `git` not using completion”

    You’re looking for:

    brew install git bash-completion

    As warpc’s comment states, you’ll need to add the following to your ~/.bash_profile to get homebrew’s bash-completion working:

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

    The above is mentioned in the caveats when you install the bash-completion formula.

    This get’s git tab completion working on OSX without having to restart your terminal:

    curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash && echo "source ~/.git-completion.bash" >> ~/.bash_profile && source ~/.bash_profile

    for some reason I was missing the file at $(brew --prefix)/etc/bash_completion so @Graham Perks’ correct answer didn’t work for me

    It ended up the fix in my case was:

    brew unlink bash-completion
    brew link bash-completion

    I solved the problem by figuring out that $(brew --prefix)/etc/bash_completion returned Permission denied when executed. So after a simple:

    chmod +x $(brew --prefix)/etc/bash_completion

    Everything is now working fine. I’m wondering why Homebrew doesn’t make the bash_completion file executable on installation, though.

    I had the same issue and even found this post this morning. I fixed the issue by updating brew with brew update and then reinstalling git with brew reinstall git.

    I was then notified of another file that is blocking the homebrew linking process, in my case it was /usr/local/share/zsh/site-functions/git-completion.bash. Removing the file and running brew link git solved the issue. Guessing it was just a bad recipe version we stumbled upon.

    Found a working solution. It’s very recent (authored 16 hours ago, and committed 2 hours ago), and it comes directly from homebrew.

    brew install git --without-completions

    Just tried it, and it finally works as intended.

    In case anyone else makes my dumb mistake, try brew install git. I was using the git that comes with Xcode and didn’t realize that I had never installed Homebrew’s git to get the autocompletions.

    Step 1: Download auto completion script:

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

    Step 2: Update .bash_profile and .bashrc

    echo "source ~/git-completion.bash" >> .bash_profile
    echo "source ~/git-completion.bash" >> .bashrc

    This will work like a charm

    Via https://www.anintegratedworld.com/git-tab-autocomplete-on-osx-10-11-el-capitan/

    It may have something to do with libedit being used instead of readline in Lion.

    Try installing readline before git.

    brew install readline

    For those who already have brew bash-completion installed. I did not have the git completion script installed and could not find any tap for that.

    So I added it manually:

    curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o $(brew --prefix)/etc/bash_completion.d/git

    Note that you have to rename the file and remove the extension for it to work.

    If you do not have completion or git installed, install it in the accepted answer.

    brew install git bash-completion

    Git Baby is a git and github fan, let's start git clone.