简体   繁体   中英

Enabling auto-completion in git bash on windows?

I would like to be able to type

git checkout <start-of-branch-name>

...and then hit tab and have the branch name autocomplete for me. How can I enable this?

First of all, the problem could be as simple as not being in a git-controlled path. Check by issuing the git status command and see if you get an error.

If you are in a git path, try to source the /etc/bash_completion.d/git file and try the tab completion again. If this works, do the following:

  1. Add the following to your ~/.bashrc file:

. /etc/bash_completion.d/git

  1. Log out.

  2. Open a new mintty session (you are using mintty, right? Tab completion might not work from "cmd" prompt or Powershell.)

  3. Type git followed by a space, then hit the Tab key twice to test. You should get a list of the git subcommands.

Tab completion on the branch name should now work for you. Eg. git branch ma <TAB> should complete as git branch master .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM