为什么git列出一个已删除的远程分支?

时间:2016-06-18 09:11:46

标签: git github

[与Why do I see a deleted remote branch?非常相似,但没有一种解决方案有效。]

forking a repository你可能得到一个你不想要的分支时:

$ git branch -a
* master
  remotes/origin/master
  remotes/origin/merge-brad

Deleting remote branches是一个很好理解的任务,所以让我们这样做:

$ git push origin :merge-brad 
To git@github.com:l0b0/fake-s3.git
 - [deleted]         merge-brad

它还在分支列表中吗?确实是的:

$ git branch -a
* master
  remotes/origin/master
  remotes/origin/merge-brad

Deleting local references to dead branches也是众所周知的。我们试试first one

$ git fetch -p
From github.com:l0b0/fake-s3
 * branch            master     -> FETCH_HEAD

都能跟得上:

$ git branch -a
* master
  remotes/origin/master
  remotes/origin/merge-brad

好吧,第二个怎么样:

$ git remote prune origin

仍然不禁:

$ git branch -a
* master
  remotes/origin/master
  remotes/origin/merge-brad

第三个:

$ git remote prune origin
$ git branch -a
* master
  remotes/origin/master
  remotes/origin/merge-brad

GitHub中的分支列表不再显示merge-brad,但本地副本拒绝承认这一点,那么现在呢? my Git configuration以某种方式打破了这个吗?

$ git --version
git version 2.8.3

1 个答案:

答案 0 :(得分:0)

我的坏。我在没有仔细查看命令的情况下应用configuration change to get upstream pull requests

git config remote.origin.fetch "+refs/pull/*/head:refs/remotes/upstream/pr/*"

我假设结果是 upstream 的拉动会检索拉请求,但当然这会修改 origin 。< / p>

修复:

$ git config remote.origin.fetch +refs/heads/*:refs/remotes/origin/*