Skip to content
AntoinePrv edited this page Jan 21, 2018 · 2 revisions

Git completion in bash

In a terminal, you can use the Tab key to trigger completion. We can add completions for the the git command , subcommands (git add, git log, git status etc.), as well as tracked files in your current project (so you can have completion for files that changed name, were deleted etc.).

The file can be found here and has more information detailed. To use it, it's very simple.

First, download the file:

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

Then, add these lines to your ".bashrc" or ".bash_profile"

if [ -f ~/.bash_git_completion ]; then
    . ~/.bash_git_completion
fi

For instance you can run this command to add the lines:

cat >> ~/.bashrc <<- EOF
if [ -f ~/.bash_git_completion ]; then
    . ~/.bash_git_completion
fi
EOF
Clone this wiki locally