git fetch 的奇怪行为

发布于 2024-10-19 01:25:13 字数 2399 浏览 9 评论 0 原文

我在 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/HEADrefs/remotes/origin/master 总是强制更新到 422b4cb...

发生了什么? 422b4cb...是一个旧的提交。

I'm getting a big problem with GIT fetch...look this

$ 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

And another 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

And another one...

$ 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

And another 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

My refs/remotes/origin/HEAD and refs/remotes/origin/master always force update to 422b4cb...

What happened? 422b4cb... is a old commit.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

会傲 2024-10-26 01:25:13

哇...在与 GIT 进行了一场激烈的斗争之后,我仅使用以下方法解决了这个问题:

git push origin :HEAD

Wow...after a big fight with GIT I fixed this issue just using:

git push origin :HEAD

宫墨修音 2024-10-26 01:25:13

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

看起来您在远程端有本地分支“HEAD”(不是特殊引用HEAD),这把它弄乱了。

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

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

注意(7 年后):使用 Git 2.16 (Q1 2018),您将无法创建名为 HEAD 的分支 无论如何。

The only other instance where I saw that kind of behavior was in this thread:

Looks like you have local branch 'HEAD' (not the special ref HEAD) on remote side and that is messing it up.

ls-remote'ing the repository shows 'refs/heads/HEAD', right (there's also HEAD, that's the required special ref)?

Maybe commit 422b4cb was when that branch called 'HEAD' was introduced?

Note (7 years later): with Git 2.16 (Q1 2018), you won't be able to create a branch named HEAD anyway.

回忆追雨的时光 2024-10-26 01:25:13

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

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

的相同

$ git push origin :HEAD

它与工作副本中 。就我而言,我们将存储库设置为拒绝分支删除,因此在这种情况下我必须登录并手动执行此操作。

I'm not sure what causes this problem, but you can fix it if you have shell access to the git repository:

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

It is the same as

$ git push origin :HEAD

in the working copy. In my case we have the repo set up to deny branch deletion, so I had to log in and do it manually in this case.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文