Autocomplete Git Branch Names in Terminal

Ann Layman
1 min readDec 3, 2018

--

Don’t waste your time by copying and pasting your long branch names- follow the steps below to use the ‘tab’ key to quickly complete the rest of the name.

  1. Open a new terminal window
  2. Run the following command: curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
  3. Access your bash_profile with nano by typing nano .bash_profile
  4. In the Nano text editor, add the following code:
if
[ -f ~/.git-completion.bash ];
then . ~/.git-completion.bash;
fi

4. Close Nano with the following commands:

ctrl + o (saves file)
press enter (confirms save)
ctrl + x (exit Nano text editor)

5. Refresh your bash_profile by typing source .bash_profile

6. Restart your terminal application to ensure your new changes will take effect

--

--