Autocomplete Git commands and Branch names in Terminal on Mac OS X

Farooq Yousuf
Apr 5, 2016 · 1 min read

If you are a user of Git on Mac OS X then sometimes it can become annoying that you cannot autocomplete the Git commands and branch names.

Luckily there is a way to fix this simple problem:

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

2. 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
fi

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

source ~/.bash_profile

You are all done now! Now type ‘git’, ‘space’, ‘tab’, you’ll get a list of all the possibilities. Same thing if you do ‘git checkout tab’ or ‘git checkout first few letters of branch name tab’.

Thanks to Code Warrior for his post:
http://code-worrier.com/blog/autocomplete-git/

Tags: autocomplete, Git


Originally published at www.farooqyousuf.net.

FusionQA

QA Engineering & Automation

Farooq Yousuf

Written by

I blog about Ruby on Rails, QA Automation and Islam.

FusionQA

FusionQA

QA Engineering & Automation

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade