refs / pull / * / head - > origin / pr / *出现在git pull上

时间:2013-07-14 21:51:58

标签: git github

大约一个月前,每当我发出'git pull'时,我最终会在我的'git branch -a'上找到一堆remotes / origin / pr / *分支,这些分支直接映射到已经在此回购中打开了拉取请求。做一个'git remote prune origin'可以清理它们。

拉前:

C:\experimental [develop]> git branch -a
* develop
  feature/291
  master
  remotes/origin/HEAD -> origin/master

拉:

C:\experimental [develop]> git pull
From https://github.com/.../experimental
 * [new ref]         refs/pull/1/head -> origin/pr/1
 * [new ref]         refs/pull/10/head -> origin/pr/10
 * [new ref]         refs/pull/100/head -> origin/pr/100
 * [new ref]         refs/pull/101/head -> origin/pr/101
 * [new ref]         refs/pull/102/head -> origin/pr/102
 * [new ref]         refs/pull/103/head -> origin/pr/103
...
 * [new ref]         refs/pull/103/head -> origin/pr/382

拉后:

C:\experimental [develop]> git branch -a
* develop
  feature/291
  master
  remotes/origin/HEAD -> origin/master
  remotes/origin/pr/1
  remotes/origin/pr/10
  remotes/origin/pr/100
  remotes/origin/pr/101
  remotes/origin/pr/102
  remotes/origin/pr/103
...
  remotes/origin/pr/382

清理:

C:\experimental [develop]> git remote prune origin
Pruning origin
URL: https://github.com/.../experimental.git
 * [pruned] origin/pr/1
 * [pruned] origin/pr/10
 * [pruned] origin/pr/100
 * [pruned] origin/pr/101
 * [pruned] origin/pr/102
 * [pruned] origin/pr/103
...
 * [pruned] origin/pr/382

清理后:

C:\experimental [develop]> git branch -a
* develop
  feature/291
  master
  remotes/origin/HEAD -> origin/master

如何阻止最初的'git pull'拉下来?它只在一个月前开始发生。

感谢。

2 个答案:

答案 0 :(得分:4)

您可能会遵循建议如何在本地检查拉取请求(请参阅https://help.github.com/articles/checking-out-pull-requests-locally)。要摆脱这一点,只需删除

fetch = +refs/pull/*/head:refs/remotes/origin/pr/*

来自.git/config

答案 1 :(得分:0)

  

不知何故,它被添加到我的系统级git config。

这可能是用于Windows(或Mac?)的GitHub,它提供了一个增强的--system配置,如您所发现的,包括:

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    fetch = +refs/pull/*/head:refs/remotes/origin/pr/*

(您可以使用git config --get-all remote.origin.fetch确认。)

如果您发现origin/pr参考资料无效,则删除refs/pull行确实可以解决问题。我个人觉得它们很有用,所以你发现的prune行为很令人沮丧:

在较旧版本的Git中,如果refs/pull行位于refs/heads行之后,remote prune将删除origin/pr引号;交换行让origin/pr refs存活。

该错误已在Git 1.9.2修复:

 * "git fetch --prune", when the right-hand-side of multiple fetch
   refspecs overlap (e.g. storing "refs/heads/*" to
   "refs/remotes/origin/*", while storing "refs/frotz/*" to
   "refs/remotes/origin/fr/*"), aggressively thought that lack of
   "refs/heads/fr/otz" on the origin site meant we should remove
   "refs/remotes/origin/fr/otz" from us, without checking their
   "refs/frotz/otz" first.

   Note that such a configuration is inherently unsafe (think what
   should happen when "refs/heads/fr/otz" does appear on the origin
   site), but that is not a reason not to be extra careful.