繁体   English   中英

Macosx git autocomplete显示已删除的分支

[英]Macosx git autocomplete shows deleted branches

我认为这可能是重复的,但我找不到我当前问题的直接答案。

我正在尝试让我的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 post中禁用自动完成远程分支在Git Bash?

我无法在最小的测试中重复这一点。 也许是一个已修复的错误? 或者你在某种程度上有标签或遥控器? 我刚用这样的本地分支测试过,看起来和你的测试类似。 在deleteme分支消失的最后一步,它不再显示在选项卡完成中。 Git版本1.8.5.2(Apple Git-48)和当前github git的完成。 最新的OSX默认bash。

$ git branch
* master
$ git checkout -b deleteme
Switched to a new branch 'deleteme'
$ git checkout master 
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
$ git checkout deleteme 
Switched to branch 'deleteme'
$ git checkout master 
Switched to branch 'master'
Your branch is up-to-date with 'origin/master'.
#completion worked for all those checkouts
$ git branch -D deleteme 
Deleted branch deleteme (was e7b6bcd).
#completion does not find any branch with de* anymore - tab-tab shows dirs in the repo
$ git checkout de
demos/ deps/  

暂无
暂无

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

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