Homebrew’s `git` not using completion Homebrew’s `git` not using completion git git

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_completionfi

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


Note: if you are using Bash v4 or later (via brew install bash) then you're going to want to use brew install bash-completion@2, to enable tab completion add the following to ~/.bash_profile as described in the caveats:

export BASH_COMPLETION_COMPAT_DIR="/usr/local/etc/bash_completion.d"[[ -r "/usr/local/etc/profile.d/bash_completion.sh" ]] && . "/usr/local/etc/profile.d/bash_completion.sh"

The additional export is necessary for git, docker, youtube-dl, and other completions which may be included in the $(brew --prefix)/etc/bash_completion.d/ directory.


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.bashecho "source ~/.git-completion.bash" >> ~/.bash_profilesource ~/.bash_profile

EDIT: this doesn't work in Catalina's default zsh shell. I changed the default shell back to bash and it works again. https://www.howtogeek.com/444596/how-to-change-the-default-shell-to-bash-in-macos-catalina/


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.