Git bash completion for Windows

Greg Foster
Greg Foster
Graphite software engineer

Git Bash completion is a functionality that auto-completes Git commands and object names as you type them in the terminal. This feature speeds up your workflow by reducing the amount of typing needed and helps avoid typos and misspellings that can lead to errors.

This guide will provide an in-depth look at enabling and using Git Bash completion on Windows.

Setting up Git Bash autocomplete on Windows involves a few steps since it isn't enabled by default like on some Linux distributions.

  1. Install Git for windows: If you haven't already, download and install Git for Windows from Git SCM. This package includes Git Bash, which is a bash emulation used to run Git from the command line.

  2. Enable autocompletion:

    • When installing Git for Windows, ensure that the option for "Git Bash Here" is selected, which typically includes bash completion scripts.
    • After installation, Git completion scripts should be automatically sourced by the Git Bash shell. If autocomplete isn't working, you might need to manually source the completion script by adding the following line to your .bashrc file:
      source /usr/share/git/completion/git-completion.bash
      This will make the file accessible from anywhere in your Git Bash terminal.
    • If the .bashrc file does not exist, you can create it by running:
    touch ~/.bashrc

    The ~ file prefix is usually the C:\Users\<your username> folder.

    • If the git-completion.bash script file does not exist in the directory, you can manually download the git-completion.bash script from the Git repository. Place this file in a directory (e.g., /usr/share/git/completion/) follow the above steps to source it from your .bashrc.
  3. Reload your Bash configuration:

    source ~/.bashrc

    Auto-completion should now be enabled from your terminal.

Once enabled, Git Bash completion allows you to start typing a Git command in the terminal and press the Tab key to auto-complete it. For example:

  • Typing git chec and pressing Tab will complete to git checkout.
  • When typing git checkout fea and pressing Tab, it will auto-complete to the nearest matching branch name that starts with "fea".
  • Speeds up workflow: Reduces the amount of typing, which speeds up your workflow.
  • Reduces errors: Helps avoid typos in Git commands and branch names, reducing potential errors.

For further reading see the official Git documentation.

Stay unblocked. Ship faster.
Experience the new developer workflow - create, review, and merge code continuously. Get started with one command.
Get started

Give your PR workflow
an upgrade today

Stack easier | Ship smaller | Review quicker

Or install our CLI.
Product Screenshot 1
Product Screenshot 2