E.g. on a fresh ubuntu machine, I\'ve just run sudo apt-get git
, and there\'s no completion when typing e.g. git check[tab]
.
I didn\'t find
May be helpful for someone:--
After downloading the .git-completion.bash from the following link,
curl https://raw.githubusercontent.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash
and trying to use __git_ps1 function, I was getting error as--
-bash: __git_ps1: command not found
Apparently we need to download scripts separately from master to make this command work, as __git_ps1 is defined in git-prompt.sh . So similar to downloading .git-completion.bash , get the git-prompt.sh:
curl -L https://raw.github.com/git/git/master/contrib/completion/git-prompt.sh > ~/.bash_git
and then add the following in your .bash_profile
source ~/.bash_git
if [ -f ~/.git-completion.bash ]; then
. ~/.git-completion.bash
export PS1='\W$(__git_ps1 "[%s]")>'
fi
source ~/.bash.git will execute the downloaded file and
export PS1='\W$(__git_ps1 "[%s]")
command will append the checkout out branch name after the current working directory(if its a git repository).
So it will look like:-
dir_Name[branch_name]
where dir_Name is the working directory name and branch_name will be the name of the branch you are currently working on.
Please note -- __git_ps1 is case sensitive.