Git autocomplete

Autocomplete git branches

Git should be part of your main workflow when working on projects. A good branching model should be part of that as well. However, switching branches is not always auto-completed using the tab key. For this, you can find a script which fixes auto completion for you.

Here’s the bash script you can run to get auto-completion:

#!/usr/bin/env bash

curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash

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

source /etc/bash_completion.d/git-prompt
source /etc/bash_completion.d/git-flow" >> ~/.bashrc

source ~/.bashrc

See also