Get Git completion to work on Linux and OS X
Admit it, bash completion is cool and having it also in git is even cooler. But when you install git from source it often doesn’t work. Here’s how to fix it.
In short, you need to have git-completion loaded in your bash. It is best for git-completion.bash to match the version of your installed git.
Download it using the command after changing 0.0.0 with your installed git version.
wget -O ~/.git-completion.bash https://raw.githubusercontent.com/git/git/v0.0.0/contrib/completion/git-completion.bash
Now you need to load it by default in your bash. Add the line below to
~/.bashrc on Linux, to
~/.bash_profile on OS X:
# adding git completion if [ -f ~/.git-completion.bash ]; then . ~/.git-completion.bash fi
if you’re running Linux or
if OS X is your OS.
If you want to, you can read more about this in the official git doc.
If it is not working for you, you have to set up bash completion. Check it here.
Thanks for reading.
Got some words you want to share? Tell me!