In bash in Mac OS X, you can use [TAB] to autocomplete file paths. Wouldn’t if be nice if you could do the same with git commands and branch names?
You can. Here’s how.
First get the
git-completion.bash script (view it here) and put it in your home directory:
Next, add the following lines to your
This tells bash to execute the git autocomplete script if it exists.
1 2 3
Now open a new shell,
cd into a git repo, and start typing a git command.
You should find that [TAB] now autocompletes git commands and git branch names.
For example, if you type
git then add a space and hit [TAB], you’ll get a readout like this, which lists all available git commands:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
Now to learn what some of these more exotic git commands do! What’s your favorite git command?
(I learned this way of installing