I've followed the process for git-completion as per the description provided at https://medium.com/@farooqyousuf/autocomplete-git-commands-and-branch-names-in-terminal-on-mac-os-x-4e0beac0388a:

The first step is to execute this command in your terminal window, this is basically grabbing the ‘git-completion.bash’ script and putting it in your home directory.

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

Now add this line to your ‘~/.bash_profile’. This will allow the execution of the git autocomplete script if it present

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

You can now restart all your terminal windows or just refresh the terminal window you wish to use this script in. To refresh do:

source ~/.bash_profile

Following is the error I'm getting while hitting tab key after typing git:

unknown option: --list-cmds=list-mainporcelain,others,nohelpers,alias,list-complete,config
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
  [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
  [-p | --paginate | --no-pager] [--no-replace-objects] [--bare]
  [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
  <command> [<args>]
  • Whaty version of git are yiuy using and what version does bash_completion ask for?
    – mmmmmm
    Commented Jun 15, 2018 at 12:49
  • git version 2.17.1 Commented Jun 15, 2018 at 12:51
  • I'm getting the same on Mac and Ubuntu too. git versions 2.4.7 and 2.17.
    – wisbucky
    Commented Jun 19, 2018 at 0:02

5 Answers 5


I ran into the exact same problem. After some digging, I finally figured out what the root problem is.

They made some major changes to the git-completion.bash script which requires a new feature in git v2.18, --list-cmds. The problem is that none of the package managers have updated to git v2.18 yet.

Most of the instructions out there say to download raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash . But that is not necessarily the best option because sometimes you will be downloading a newer git-completion.bash than your version of git supports.

So the solution is to download the git-completion.bash version that matches your git version. Then source it again. In this case:


Notice that it is referencing v2.17.1 instead of master. Later, when you install git v2.18, then you can switch back to master, or v2.18 tag.


Upgrading the git to the latest version is the simplest solution. https://git-scm.com/download/mac

After that make sure you follow the steps

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

  2. Add this small command into the .bash_profile file if [ -f ~/.git-completion.bash ]; then . ~/.git-completion.bash fi


Don't build it from source; instead install from MacPorts.

To install git with auto-completion, issue the following command:

 $ sudo port install git +bash_completion

close and reopen your Terminal and git completion should work

  • I've tried this but didn't resolve the issue. It's still the same. Commented Jun 15, 2018 at 12:40
  • Issue this command: sudo find / -type -name "git-completion.bash" and post the results to your question.
    – Allan
    Commented Jun 15, 2018 at 13:17

You should verify your git version and make sure it is updated to at least 1.8.

I had an older version 1.7.11 but that didn't work and got the same error you have.


If you use Homebrew, you may want to

  1. upgrade git:

    brew upgrade git

  2. source the installed git-completion.bash in your ~/.bash_profile:

    . /usr/local/etc/bash_completion.d/git-completion.bash

This makes sure the installed git and completion script versions match.

You must log in to answer this question.

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