How to configure git bash command line completion?

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 anything on, but IIRC completion is included in the git package these days and I just need the right entry in my bashrc.

  • Run git pull over all subdirectories
  • How do I get Git's latest stable release version number?
  • Starting a SourceTree git project from scratch
  • Git post-receive deployment stops working at random points
  • Is it possible to write a script on a server side hook on github
  • Git Bash is displaying strange characters on Windows 7
  • Automatically write changelog to in GitHub
  • How does Git decide where to save secret tokens exactly?
  • How to upload a json file with secret keys to Heroku
  • Showing which files have changed between two revisions
  • Pull/merge uncommitted changes
  • .gitignore: Ignore one specific directory and that one only
  • 8 Solutions collect form web for “How to configure git bash command line completion?”

    On Linux

    on most distributions, git completion script is installed into /etc/bash_completion.d/ (or /usr/share/bash-completion/completions/git) when you install git, no need to go to github. You just need to use it – add this line to your .bashrc:

    source /etc/bash_completion.d/git
    # or
    source /usr/share/bash-completion/completions/git

    In some versions of Ubuntu, git autocomplete may be broken by default, reinstalling by running this command should fix it:

    sudo apt-get install git-core bash-completion

    On Mac

    You can install git completion using Homebrew or MacPorts.


    brew install bash-completion

    then add this to your .bash_profile:

    if [ -f `brew --prefix`/etc/bash_completion ]; then
        . `brew --prefix`/etc/bash_completion


    sudo port install git +bash_completion

    then add this to your .bash_profile:

    if [ -f /usr/share/bash-completion/bash_completion ]; then
        . /usr/share/bash-completion/bash_completion

    more info in this guide: Install Bash git completion

    Note that in all cases you need to create a new shell (open a new terminal tab/window) for changes to take effect.

    i had same issue, followed below steps:

    curl -o ~/.git-completion.bash

    then add the following lines to your .bash_profile (generally under your home folder)

    if [ -f ~/.git-completion.bash ]; then
      . ~/.git-completion.bash

    source :


    You just need to source the completion script

    Ubuntu 14.10

    Install git-core and bash-completion

    sudo apt-get install -y git-core bash-completion
    • For current session usage

      source /usr/share/bash-completion/completions/git
    • To have it always on for all sessions

      echo "source /usr/share/bash-completion/completions/git" >> ~/.bashrc

    on my ubuntu there is a file installed here :

    source /etc/bash_completion.d/git-prompt

    you can follow the links into the /usr/lib/git-core folder. You can find there an instruction, how to set up PS1 or use `__git_ps1

    May be helpful for someone:–

    After downloading the .git-completion.bash from the following link,

    curl -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 . So similar to downloading .git-completion.bash , get the

    curl -L > ~/.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]")>'

    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.


    There is a beautiful answer here. Worked for me on Ubuntu 16.04


    Git Bash is the tool to allow auto-completion. Not sure if this is a part of standard distribution so you can find this link also useful.
    By the way, Git Bash allows to use Linux shell commands to work on windows, which is a great thing for people, who have experience in GNU/Linux environment.

    On Github in the Git project, They provide a bash file to autocomplete git commands.

    You should download it to home directory and you should force bash to run it. It is simply two steps and perfectly explained(step by step) in the following blog post.

    code-worrier blog: autocomplete-git/

    I have tested it on mac, it should work on other systems too. You can apply same approach to other operating systems.

    Git Baby is a git and github fan, let's start git clone.