In Ubuntu, this comes out of the box but in terminal on OSX a few extra steps are required to get this to work. It is a bit of a hassle figuring out what needs to be done, but once you know, it literally takes 10 seconds.
Step 1: Download auto completion script:
>> cd ~ >> curl -O https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash
This downloads the auto completion script.
Step 2: Update .bash_profile
>> echo "source ~/git-completion.bash" >> .bash_profile
This adds an extra line into your .bash_profile
That is it! Easy as.
- You may need to restart terminal.
- You want to curl the “raw” version of this file: https://github.com/git/git/blob/master/contrib/completion/git-completion.bash so add raw as a subdomain (raw.github.com/etc….) and you’ll see the redirect.
- The -O flag in curl means to download it as a file. Otherwise you’ll see the file echoed out in the terminal.