Git bash completion for Windows

Greg Foster
Greg Foster
Graphite software engineer


Note

This guide explains this concept in vanilla Git. For Graphite documentation, see our CLI docs.


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.

Join 20,000+ developers at top companies
Stop wrestling with Git commands
The Graphite CLI takes all the pain out of Git, allowing you to ship faster and stop googling Git commands.
main
diff1
diff2

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:
      Terminal
      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:
    Terminal
    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:

    Terminal
    source ~/.bashrc

    Auto-completion should now be enabled from your terminal.

Join 20,000+ developers at top companies
The best engineers use Graphite to simplify Git
Engineers at Vercel, Snowflake & The Browser Company are shipping faster and staying unblocked with Graphite.
main
diff1
diff2

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.

Git inspired
Graphite's CLI and VS Code extension make working with Git effortless.
Learn more

Graphite
Git stacked on GitHub

Stacked pull requests are easier to read, easier to write, and easier to manage.
Teams that stack ship better software, faster.

Or install our CLI.
Product Screenshot 1
Product Screenshot 2