Autocompletion for git commands

Requirement: it would be great to get autocompletion for git commands in mac terminal.

Install Git download

Now we need to download bash file with all commands. Open terminal and run this command from Home directory.

curl -O .git-completion.bash

Now check for .bash_profile in your home directory. open terminal
This command should show all invisible file also.


Create file .bash_profile if it doesn’t exist.

touch .bash_profile

Open file .bash_profile in text editor or editor of your choice.

open .bash_profile

Now append this code for .bash_profile file.

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

Save it and close the terminal.

Open the terminal.
type > git h
This should complete command as “git help”

Verify 2:

You can get completion for git command options also.
git log –a
this should list all possible options start with “–a”.