Bash autocompletion for Git

Published on and tagged with git

One thing I often wished to have when using Git was the ability to autocomplete Git commands and branch names. As I had to learn this week from Markus Prinz’ article A few of my Git tricks, tips and workflows, Git comes with an autocompletion script for the Bash shell.

But to use the autocompletion, you have to enable it. To do that, add the following snippet to your ~/.bashrc file (if you are using a Mac, see the aforementioned article):

source /etc/bash_completion.d/git

You can then either reload the .bashrc file with source ~/.bashrc or open a new shell to see the autocompletion in action.

10 comments baked

© daniel hofstetter. Licensed under a Creative Commons License