我认为这可能是重复的,但我找不到我当前问题的直接答案。
我正在尝试让我的 macosx git autocomplete 工作起来类似于我在 linux 机器上工作的 git autocomplete。我找到了一些指导我安装 https://github.com/git/git/tree/master/contrib/completion 的说明(我使用的是 .bash 版本)。一切正常,唯一的问题是现在自动完成显示已删除的分支。
有没有人有替代脚本/方法,或者甚至只是关于如何编辑当前脚本以避免显示我的所有分支以及仅显示可用的当前本地分支的说明。
谢谢你 布罗迪
[编辑]
我认为可以举个例子来帮助使问题更清楚。
#result of git branch is as expected
$ git branch
*master
somefeature
someotherfeature
#now I delete one of my feature branches
$ git branch -D someotherfeature
$ git branch
*master
somefeature
#the branch someotherfeature is gone, as expected
#however when I attempt an autocomplete, like with git checkout, I get everything remote branches, local branches, and previously deeted branches.
$ git checkout <tab><tab>
master somefeature someotherfeature remote/origin/master remote/origin/remotebranch
我想让它像在我的 linux 机器上一样显示我的本地分支
# i.e. given 2 local branches `master` and `somefeature` autocomplete would work as follows
$ git checkout <tab><tab>
master somefeature
最佳答案
在我的 git-completion.bash
版本中,我可以执行以下操作来防止这些已删除的分支显示为完成的一部分:
export GIT_COMPLETION_CHECKOUT_NO_GUESS=1
我发现它在文件 (homebrew - /usr/local/Cellar/git/2.19.2/share/zsh/site-functions/git-completion.bash
) 和也在SO 帖子 Disable auto-completion of remote branches in Git Bash? .
关于git - macos git autocomplete 显示删除的分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23569688/