根据主分支重新建立分离的 HEAD

发布于 2024-11-12 05:34:48 字数 319 浏览 2 评论 0原文

我在工作中使用 gerrit,它需要使用 rebase 而不是合并提交。今天,我使用其哈希值检查了之前的提交,当我运行 gitbranch 命令时,我被告知我处于“无分支”状态。我认为这是一个独立的头?无论如何,我根据我的主分支进行了重新调整,控制台打印出

Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...

这种情况下的“3路合并”来自哪里?变基后 HEAD 是否仍然分离(考虑“base-tree”语句)?谢谢。

I use gerrit at my job, and it requires use of rebase instead of merge commits. Today I checked out a previous commit using its hash value, and when I ran the git branch command, I was informed I was on "no branch". I assume this is a detached HEAD? In any case, I rebased against my my master branch, and the console printed

Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...

Where does the '3-way merge' in this situation come from? And was the HEAD still detached after the rebase (considering the 'base-tree' statement)? Thank you.

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

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

发布评论

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

评论(2

2024-11-19 05:34:48

是的,“无分支”意味着分离的 HEAD

基本修订来自于执行

git merge-base <yourrevision> master

它将查看最后一个共同祖先(或合并点,即使存在手动冲突,也被认为是共同祖先)来建立一个基础版本。

变基后,您通常始终位于新的分离头 IIRC 上。现在有多种方法可以调用 rebase(包括 --onto --root),并且它们的行为可能略有不同。因此,如果您愿意发布所使用的 rebase 命令,我可能会验证我的想法,并可能添加一些评论。

Yes 'no branch' means detached HEAD

The base revision comes from doing

git merge-base <yourrevision> master

It will look at the last common ancestor (or merge point, which is considered a common ancestor even if there were manual conflicts) to establish a base version.

After a rebase, you are normally always on a new detached HEAD, IIRC. Now there are numerous ways in which to call rebase (including --onto --root) and they may behave slightly differently. So if you care to post the rebase command used, I may verify my thinking and perhaps add some comments.

眼泪淡了忧伤 2024-11-19 05:34:48

正如此处所示所示,此错误消息通常是冲突的迹象:

冲突不会自行消失,但在这种情况下,我们修复冲突并继续,原始补丁“添加了另一条消息”将自行更改:

$ vi main.c
$ git add main.c
$ git rebase --continue

关键是修复后继续 rebase冲突。

As illustrated here, this error message is usually the sign of a conflict:

The conflict does not go away by itself, but in this case we fix the conflict and continue, and the original patch "Added another message" will be itself changed:

$ vi main.c
$ git add main.c
$ git rebase --continue

The key is to continue the rebase after fixing the conflict.

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