9

我在使用 GIT fetch 时遇到了一个大问题……看这个

$ git fetch
From server:project
   422b4cb..a04c062  master     -> origin/master

$ git show-ref
ba113be885e66a5306d1646cd3db0801170c04f8 refs/heads/alpha-release
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/master
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/test
a04c062261beeb4a951337ebb58745945cac3562 refs/remotes/origin/HEAD
ba113be885e66a5306d1646cd3db0801170c04f8 refs/remotes/origin/alpha-release
a04c062261beeb4a951337ebb58745945cac3562 refs/remotes/origin/master

还有一个git fetch

$ git fetch
From server:project
 + a04c062...422b4cb HEAD       -> origin/HEAD  (forced update)

$ git show-ref
ba113be885e66a5306d1646cd3db0801170c04f8 refs/heads/alpha-release
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/master
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/test
422b4cbac3db2784c8f6e94ffd99c7afcda9122d refs/remotes/origin/HEAD
ba113be885e66a5306d1646cd3db0801170c04f8 refs/remotes/origin/alpha-release
422b4cbac3db2784c8f6e94ffd99c7afcda9122d refs/remotes/origin/master

还有一个...

$ git fetch
From server:project
   422b4cb..a04c062  master     -> origin/master

$ git show-ref
ba113be885e66a5306d1646cd3db0801170c04f8 refs/heads/alpha-release
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/master
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/test
a04c062261beeb4a951337ebb58745945cac3562 refs/remotes/origin/HEAD
ba113be885e66a5306d1646cd3db0801170c04f8 refs/remotes/origin/alpha-release
a04c062261beeb4a951337ebb58745945cac3562 refs/remotes/origin/master

还有一个git fetch

$ git fetch
From server:project
 + a04c062...422b4cb HEAD       -> origin/HEAD  (forced update)

$ git show-ref
ba113be885e66a5306d1646cd3db0801170c04f8 refs/heads/alpha-release
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/master
a04c062261beeb4a951337ebb58745945cac3562 refs/heads/test
422b4cbac3db2784c8f6e94ffd99c7afcda9122d refs/remotes/origin/HEAD
ba113be885e66a5306d1646cd3db0801170c04f8 refs/remotes/origin/alpha-release
422b4cbac3db2784c8f6e94ffd99c7afcda9122d refs/remotes/origin/master

我的refs/remotes/origin/HEAD并且refs/remotes/origin/master总是强制更新到422b4cb...

发生了什么?422b4cb...是一个旧的承诺。

4

3 回答 3

12

哇...在与 GIT 大吵一架后,我使用以下方法解决了这个问题:

git push origin :HEAD

于 2011-02-23T19:09:51.603 回答
4

我看到这种行为的唯一另一个例子是在这个线程中:

看起来你在远程端有本地分支 ' HEAD' (不是特殊的 ref HEAD),这把它搞砸了。

ls-remote'ing 存储库显示' refs/heads/HEAD',对(还有 HEAD,这是所需的特殊参考)?

也许提交422b4cb是在引入名为 ' ' 的分支时HEAD

注意(7 年后):使用Git 2.16(2018 年第一季度),您将无法创建名为 HEAD 的分支

于 2011-02-23T18:32:13.383 回答
1

我不确定是什么导致了这个问题,但如果你有对 git 存储库的 shell 访问权限,你可以修复它:

$ [ ... log into shell on git server ...]
$ cd /path/to/repo.git
$ rm refs/heads/HEAD

它与

$ git push origin :HEAD

在工作副本中。在我的情况下,我们将 repo 设置为拒绝删除分支,因此在这种情况下我必须登录并手动执行。

于 2011-07-22T21:54:58.833 回答