简体   繁体   English

在Windows上的git bash中启用自动补全功能?

[英]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. 首先,问题可能很简单,就像不在git控制的路径中一样。 Check by issuing the git status command and see if you get an error. 通过发出git status命令进行检查,看看是否出现错误。

If you are in a git path, try to source the /etc/bash_completion.d/git file and try the tab completion again. 如果您在git路径中,请尝试获取/etc/bash_completion.d/git文件的源,然后再次尝试制表符/etc/bash_completion.d/git If this works, do the following: 如果可行,请执行以下操作:

  1. Add the following to your ~/.bashrc file: 将以下内容添加到您的~/.bashrc文件中:

. /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.) 打开一个新的薄荷会话(您正在使用薄荷,对吗?在“ cmd”提示或Powershell中,制表符补全可能无法正常工作。)

  3. Type git followed by a space, then hit the Tab key twice to test. 键入git后跟一个空格,然后按两次Tab键进行测试。 You should get a list of the git subcommands. 您应该获得git子命令的列表。

Tab completion on the branch name should now work for you. 现在,分支名称上的制表符补全应该适合您。 Eg. 例如。 git branch ma <TAB> should complete as git branch master . git branch ma <TAB>应该作为git branch master完成。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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