Last active
May 26, 2023 08:16
-
-
Save jpalmieri/078cbb0581de5c53f3b7 to your computer and use it in GitHub Desktop.
Autocomplete for git commands and branch names
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Taken from this page: http://code-worrier.com/blog/autocomplete-git/ | |
Step 1: download this bash script (make sure to name it ".git-completion.bash"): | |
https://github.com/git/git/blob/master/contrib/completion/git-completion.bash. | |
You can run this curl from your home directory to download it directly: | |
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash | |
Step 2: Place the file in your home directory | |
Step 3: add the following lines to your .bash_profile: | |
if [ -f ~/.git-completion.bash ]; then | |
. ~/.git-completion.bash | |
fi | |
Step 4: Close all Terminal windows and reopen. If it still doesn't work, make the script executable: | |
chmod -X ~/.git-completion.bash (per this reference: http://apple.stackexchange.com/questions/55875/git-auto-complete-for-branches-at-the-command-line) | |
Then restart Terminal. | |
You should now be able to use tab to autocomplete git commands and branch names, just like files and directories. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment