Skip to content

Instantly share code, notes, and snippets.

@by12380
Last active July 11, 2020 00:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save by12380/fddca6642a08618a9258ae3e5eade3af to your computer and use it in GitHub Desktop.
Save by12380/fddca6642a08618a9258ae3e5eade3af to your computer and use it in GitHub Desktop.
Git branch autocompletion

Source: https://davidwalsh.name/git-branch-autocompletion

Start by downloading the git-completion.sh file from GitHub:

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

Next, add the following to your ~/.bash_profile file:

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

The last step is restarting your terminal. Voila! Now you can type git checkout {search-string} and press tab to select the lone branch that matches or hit tab again to see all matches!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment