How to Set up Git Tab Completion

John John (304)
5 minutes

Tab completion, or auto-completion, is essential if you're using Git on the command line. Tab completion is a nice feature of many shells that allows you to complete a word by hitting tab. In this case, we want to be able to use tab completion for things like branches and tags in git. Fortunately, setting it up is pretty simple.

Posted in these interests:
h/git16 guides

First, open a shell and navigate to your home directory because that's where the script will reside.


Now download the git completion script using one of the following methods.

Using curl:

curl -O

Using wget:

source ~/git-completion.bash

In most cases, you'll want to source this file automatically whenever you start a new shell. To do so, open your ~/.bashrc file and append the command from above. Once you save the file, all new shells will automatically source the file.

Note: The tilde (~) refers to your home directory.

Move to a git controlled directory and type:

git checkout <tab><tab>

You should see a list of all of the possible branches that can be checked out!

Zach Zach (248)
2 minutes

By default, CTRL-TAB and SHIFT-CTRL-TAB don't operate in the same way that Google Chrome's tab cycling does. For example, when you press CTRL-TAB, it doesn't always cycle to the next open document.