10

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 be git 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:

enter image description here

How do I resolve this?

Community
  • 1
  • 1
MysticCode
  • 151
  • 1
  • 1
  • 7

2 Answers2

35

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
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
1
  1. Install git & bash-completion

    sudo apt-get install git bash-completion -y
    
  2. Download the matched version of git-completion.bash (You can change the version in the following download link)

Example:

  1. Source this git-completion.bash

    . git-completion.bash
    

Enjoy it

W. Dan
  • 906
  • 8
  • 10