git 错误:远程 HEAD 不明确,可能是以下之一

发布于 2024-08-27 06:46:18 字数 759 浏览 5 评论 0原文

分支并推送到远程后,git remote show origin 给出报告

HEAD branch (remote HEAD is ambiguous, may be one of the following):  
    master  
    otherbranch  

What does the imply?

这是一个严重错误吗?

remote origin
  Fetch URL: [email protected]:/home/gituser/repos/csfsconf.git
  Push  URL: [email protected]:/home/gituser/repos/csfsconf.git
  HEAD branch (remote HEAD is ambiguous, may be one of the following):
    master
    otherbranch

After branching and pushing to the remote, a git remote show origin gives the report

HEAD branch (remote HEAD is ambiguous, may be one of the following):  
    master  
    otherbranch  

What does the imply?

It is a critical error?

remote origin
  Fetch URL: [email protected]:/home/gituser/repos/csfsconf.git
  Push  URL: [email protected]:/home/gituser/repos/csfsconf.git
  HEAD branch (remote HEAD is ambiguous, may be one of the following):
    master
    otherbranch

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

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

发布评论

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

评论(2

独留℉清风醉 2024-09-03 06:46:18

您可以在此博文

(master)jj@im-jj:~/demo$ git checkout -b rc-1.0
Switched to a new branch 'rc-1.0'
(rc-1.0)jj@im-jj:~/demo$ git push origin rc-1.0
Total 0 (delta 0), reused 0 (delta 0)
To my-server:/git/demo.git
 * [new branch]      rc-1.0 -> rc-1.0
(rc-1.0)jj@im-jj:~/demo$ git remote show origin 
* remote origin
  URL: my-server:/git/demo.git
  HEAD branch (remote HEAD is ambiguous, may be one of the following):
    master
    rc-1.0
  Remote branches:
    master tracked
    rc-1.0 tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local refs configured for 'git push':
    master pushes to master (up to date)
    rc-1.0 pushes to rc-1.0 (up to date)

short log

这(推送新的当前分支)将引入对远程存储库的新 HEAD 引用。

如果您查看此警告消息的 Git 源,它会尝试获取通过 get_head_names() 调用远程 HEAD 名称:

matches = guess_remote_head(find_ref_by_name(remote_refs, "HEAD"),
+                   fetch_map, 1);

此补丁

确定 HEAD 是不明确的,因为它是通过比较 SHA1 来完成的。

(请参阅代码在这里

在多个匹配的情况下,如果匹配,我们返回 refs/heads/master,否则我们返回遇到的第一个匹配。 builtin-remote 需要返回所有匹配项,因此请添加一个标志来请求此类。

You can see the same warning in this blog post

(master)jj@im-jj:~/demo$ git checkout -b rc-1.0
Switched to a new branch 'rc-1.0'
(rc-1.0)jj@im-jj:~/demo$ git push origin rc-1.0
Total 0 (delta 0), reused 0 (delta 0)
To my-server:/git/demo.git
 * [new branch]      rc-1.0 -> rc-1.0
(rc-1.0)jj@im-jj:~/demo$ git remote show origin 
* remote origin
  URL: my-server:/git/demo.git
  HEAD branch (remote HEAD is ambiguous, may be one of the following):
    master
    rc-1.0
  Remote branches:
    master tracked
    rc-1.0 tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local refs configured for 'git push':
    master pushes to master (up to date)
    rc-1.0 pushes to rc-1.0 (up to date)

short log

That (pushing a new current branch) will introduce a new HEAD reference to the remote repo.

If you look at the Git sources for this warning message, it tries to get the remote HEAD names through get_head_names() which calls :

matches = guess_remote_head(find_ref_by_name(remote_refs, "HEAD"),
+                   fetch_map, 1);

As described in this patch:

Determining HEAD is ambiguous since it is done by comparing SHA1s.

(see the code here)

In the case of multiple matches we return refs/heads/master if it matches, else we return the first match we encounter. builtin-remote needs all matches returned to it, so add a flag for it to request such.

傲世九天 2024-09-03 06:46:18

线程位于 http://forums.wf.klevo.sk/comments.php ?DiscussionID=155对此主题进行了讨论。该线程特别提到:

# make a new branch where you can make and commit changes to
$git checkout -b darth-kool
Switched to a new branch 'darth-kool'

# * marks current branch
$git branch -l
* darth-kool
master

也许您需要标记当前分支?如果没有,线程的其余部分可能会有所帮助。

The thread at http://forums.wf.klevo.sk/comments.php?DiscussionID=155 has a discussion of this topic. In particular the thread mentions:

# make a new branch where you can make and commit changes to
$git checkout -b darth-kool
Switched to a new branch 'darth-kool'

# * marks current branch
$git branch -l
* darth-kool
master

Perhaps you need to mark your current branch? If not, the rest of the thread may help.

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