Git and git-flow command line completion

I switch between the command line and a GUI tool called SourceTree to manage my Git repositories.  When I first installed git-flow, I noticed that the readme talked about command line completion.  It took me a while to get around to installing it, but I have to say that it is really impressive.

Git and git-flow command line completion works like the rest of bash against the file system.  It reminds me a little of PowerShell on Windows (that should tell you how much I know about bash).

To install command line completion on a Mac, you need to find a copy of the git-completion.bash script.  Some of the posts I read on the net seem to indicate that it should be installed with Git in a contrib folder, but I couldn’t find it (showing how new I am on a Mac), so I decided to just clone Git from Git-Hub. Once I had that, I created a link to the script in my ~/bin directory:

cd ~/src/external
git clone git
cd ~
mkdir bin
ln -s ~/src/external/git/contrib/completion/git-completion.bash ./

I did a similar thing for git-flow-completion:

cd ~/src/external
git clone git-flow-completion
cd ~/bin
ln -s ~/src/external/git-flow-completion/git-flow-completion.bash ./

The next thing to do is to modify your .bash_profile to call those scripts.

source ~/bin/
source ~/bin/

Now when you execute git commands from the command line, you can use tab to complete commands, branches, remotes, and features. On top of that, it works for both local and remote elements. Very cool!


One thought on “Git and git-flow command line completion

  1. Alan

    I like how the first URL that you must clone from has ‘git’ in it five different times.

    Nice write up! Keep them coming.


Leave a Reply

Your email address will not be published. Required fields are marked *