Macosx git autocomplete显示已删除的分支

Bro*_*die 7 git

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

我正在尝试让我的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 
Run Code Online (Sandbox Code Playgroud)

我想让它只显示我的本地分支,就像它在我的linux盒子上一样

# i.e. given 2 local branches `master` and `somefeature` autocomplete would work as follows
$ git checkout <tab><tab>
  master    somefeature
Run Code Online (Sandbox Code Playgroud)

Han*_*kCa 5

在我的版本中,git-completion.bash我可以执行以下操作以防止这些已删除的分支显示为完成的一部分:

export GIT_COMPLETION_CHECKOUT_NO_GUESS=1
Run Code Online (Sandbox Code Playgroud)

我发现它在文件 (homebrew - /usr/local/Cellar/git/2.19.2/share/zsh/site-functions/git-completion.bash) 和 SO post Disable auto-completion of remote branch in Git Bash 中提到过.