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”.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s