Git Auto-complete not working in bash
14,103
Use this script for Ubuntu:
https://github.com/git/git/blob/master/contrib/completion/git-completion.bash
Read the documentation on how to set it up:
To use these routines:
1) Copy this file to somewhere (e.g. ~/.git-completion.bash).
2) Add the following line to your .bashrc/.zshrc:
source ~/.git-completion.bash
3) Consider changing your PS1 to also show the current branch,
see git-prompt.sh for details.
A shorter solution:
# install the bash-completion vai apg-get
sudo apt-get install git bash-completion
Author by
MysticCode
Updated on July 27, 2022Comments
-
MysticCode almost 2 years
I recently installed git. I am using Ubuntu 14.04. However the autocomplete feature is not working.
Whenever I type
git i
then TAB it should begit init
but it doesn't happen so. I have tried everything mentioned in this page, still no success.Whenever I do
git in
then TAB it seems like git is pinging unknown host. Below is the screenshot:How do I resolve this?
-
MysticCode about 8 yearsI did step 1 and 2 still no success.
-
CodeWizard about 8 yearstry the updated apt-get option and update me if it working or not
-
MysticCode about 8 yearsThat also did not work out. It says bash-completion is already the newest version
-
CodeWizard about 8 yearsOk, now try to source it:
source ~/.git-completion.bash
. if still not working try to set the chmod 664/755 on this file -
MysticCode about 8 yearsI dont know but the problem still persists. I also tried changing the permissions. I also have sourced .git-completion.bash in my .bashrc. .git-completion.bash also exists in my home directory. I don't know what the problem is
-
MysticCode about 8 yearsFinally resolved the problem. The problem seemed to be with my .bashrc file ..i replaced ~/.bashrc with /etc/skel/.bashrc now its working
-
Asalle about 7 yearsThe shorter solution did not work for me, but the former one did.
-
Martin Lyne about 6 yearsLong oslution didn't work for me on Xenial, but shorter one did 👌
-
Erasmus Cedernaes almost 6 years@MysticCode The
/etc/skel/.bashrc
was the solution for me as well. You should add it as an answer and mark it as the solution. -
MountainDrew almost 4 yearsThe "shorter solution" of this answer worked for me, though I had to close my terminal and open a new terminal in order for it to take effect.
-
J.Ko about 3 yearsJust running the second step worked for me.