Why does debian not autocomplete all git commands?

Posted on

Problem :

I am running debian

$ cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
NAME="Debian GNU/Linux"
VERSION_ID="9"
VERSION="9 (stretch)"
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL="https://bugs.debian.org/"

I installed git, and tried to get git autocompletion. Reading long ago, I noticed I needed to install bash-completion.

I did this, and worked for a lot of autocompletion commands:

sudo apt-get install git bash-completion

However, there are still some git commands it does not autocomplete. i.e:

git stash list --name-only (Does not autocomplete --name-only)

Why is this? Can I fix it somehow?

Solution :

Last time I checked, the Git autocompletion contained in the bash-completion package offered fewer functions than the one that ships with Git itself.

I’d recommend to download a recent one, and source that:

curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash

Then add to your ~/.bash_profile

[ -f ~/.git-completion.bash ] && . ~/.git-completion.bash

More info is available on the Git website.

Leave a Reply

Your email address will not be published. Required fields are marked *