我在我的一个Git存储库中看到了奇怪的行为。克隆后不久我就看到了这种情况:
$ git show-ref
06e26a871527e0a5dfaffa3d01887448939fb621 refs/heads/master
06e26a871527e0a5dfaffa3d01887448939fb621 refs/remotes/origin/HEAD
f9a40b7da2a67469303124a79ac79d308835e2eb refs/remotes/origin/acl
06e26a871527e0a5dfaffa3d01887448939fb621 refs/remotes/origin/master
存储库的正确和最后状态。如果运行一个fetch(同时没有任何提交),我得到:
$ git fetch
From <my company git server>:<working repo>
+ 06e26a8...c9584e2 HEAD -> origin/HEAD (forced update)
导致:
$ git show-ref
06e26a871527e0a5dfaffa3d01887448939fb621 refs/heads/master
c9584e24b5e12338d926c1547eed3eefeca671cb refs/remotes/origin/HEAD
f9a40b7da2a67469303124a79ac79d308835e2eb refs/remotes/origin/acl
c9584e24b5e12338d926c1547eed3eefeca671cb refs/remotes/origin/master
如果我再次运行fetch,我会回到正确的状态:
$ git fetch
From <my company git server>:<working repo>
c9584e2..06e26a8 master -> origin/master
提交c9584e24b5e12338d926c1547eed3eefeca671cb是一个非常古老的,似乎原点/ HEAD卡在那里,创造了这种弹跳行为。
此外,如果本地存储库状态正确且有人推送更改,我在获取它时收到错误消息:
$ git fetch origin
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From <my company git server>:<working repo>
06e26a8..5385a49 master -> origin/master
error: Ref refs/remotes/origin/master is at 5385a494927519644978ddfc975d4a0e94628d93 but expected 06e26a871527e0a5dfaffa3d01887448939fb621
! 06e26a8...c9584e2 HEAD -> origin/HEAD (unable to update local ref)
我必须再次运行git fetch来获取更新。
在Ubuntu机器上使用git版本1.7.9.5(我在几台机器上试过)会发生这种情况,而windows下的git 1.7.11.msysgit.1似乎表现正常。
有人可以解释一下这个存储库发生了什么,我该如何解决这个问题?