Autocomplete Git Branch Names in Terminal
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.
- Open a new terminal window
- Run the following command:
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
- Access your bash_profile with nano by typing
nano .bash_profile
- 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