Git auto-completion for the bash shell

You can enable auto-completion for Git commands in the bash shell. For this copy the following file to your home directory under the name “.git-completion.bash”.

git-completion.bash in the main Git repository.

Afterwards add the following lines to your .bashrc file and restart the bash.

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

Now you have code completion, e.g. if you type git c and press tag you see the possible values.

About Lars Vogel

Lars Vogel is the founder and CEO of the vogella GmbH and works as Eclipse and Android consultant, trainer and book author. He is a regular speaker at international conferences, He is the primary author of With more than one million visitors per month this website is one of the central sources for Java, Eclipse and Android programming information.
This entry was posted in Lars Vogel, Other and tagged . Bookmark the permalink.

4 Responses to Git auto-completion for the bash shell

  1. Daniel Shwering says:

    I believe the relevant line to be inserted into .bashrc is missing…

  2. pawel says:

    Did’t you forget to post the “following line” or I can’t find ?

  3. Lars Vogel says:

    Thanks, yes forgot the relevant line. Now it should be visible.

  4. Sorry Lars, but I have to say this – you get this behaviour out of the box after installation of Fedora linux ;-).

Comments are closed.