redochka redochka - 1 year ago 118
Linux Question

How can I set up autocompletion for Git commands?

I have Git (version bash compeletion working on my Debian squeeze (6.0). Git was installed with aptitude and I am using standard debian's

, which supports command line autocompletion.

Now, I just installed Git ( on an other machine (Lenny/Debian 5.0) and the there is no autocompletion.

  1. Why is Git autocomplete not working on the second machine? How do I diagnose this?

  2. What is making completion work on my machine? I have looked for the file
    but it doesn't seem to be on my machine. How does Git complete ever work?

  3. How can I bring git complete to the other machine?

Answer Source

You need to source /etc/bash_completion.d/git to enable git auto-completion.

In my .bashrc it's done with:

for file in /etc/bash_completion.d/* ; do
    source "$file"