In Linux
on most distributions, the git completion script is installed in /etc/bash_completion.d/ (or /usr/share/bash-completion/completions/git ) when installing git, there is no need to switch to github. You just need to use it - add this line to your .bashrc :
source /etc/bash_completion.d/git
On some versions of Ubuntu, git autocomplete may be broken by default, reinstalling with this command should fix this:
sudo apt-get install git-core bash-completion
On mac
You can install git complete using Homebrew or MacPorts.
Homebrew
if $BASH_VERSION > 4: brew install bash-completion@2 $BASH_VERSION brew install bash-completion@2 (updated version) Pay particular attention to what version of bash you have as MacOS with 3.2.57 by default (1) -release.
add to .bash_profile :
if [ -f /usr/local/share/bash-completion/bash_completion ]; then . /usr/local/share/bash-completion/bash_completion fi
For older versions of bash: brew install bash-completion
add to .bash_profile :
[ -f /usr/local/etc/bash_completion ] && . /usr/local/etc/bash_completion
Macports
sudo port install git +bash_completion
then add this to your .bash_profile :
if [ -f /usr/share/bash-completion/bash_completion ]; then . /usr/share/bash-completion/bash_completion fi
more information in this guide: Install Bash Git Completion
Please note that in all cases you need to create a new shell (open a new tab / terminal window) for the changes to take effect.
Sergey Evstifeev Sep 19 '13 at 15:16 2013-09-19 15:16
source share