gpt4 book ai didi

git - merge 我的分支后出现 "git revert"问题

转载 作者:行者123 更新时间:2023-12-03 19:13:44 25 4
gpt4 key购买 nike

我有三个分支:master,A 和 B。

分支“A”和“B”应该相互独立。 pull 请求后,master 从 A 和 B 更新。 现在,我不小心将 B merge 到 A 中。

我立即通过 git revert -m 恢复了此 merge 。

但是现在当我将 B pull 入 master 时,A 中的还原 merge 会破坏分支 B 的更改。这是因为分支 A 具有“还原 merge B”提交。

如何删除“还原 merge 分支 B”和“merge 分支 B”提交?
我尝试使用 git -rebase 命令,但它对我没有帮助,git 创建了不在 pull 请求中的 anthoer 分支。

最佳答案

简单回答: git docs

还原还原因为

So if you think of "revert" as "undo", then you're going to always miss this part of reverts. Yes, it undoes the data, but no, it doesn't undo history.



添加更多内容:

不幸的是,你打了 HitTest 门的问题在 git 用户的历史中 :)

您的问题是 merge 错误 git merge branch B/branch A ,您试图通过 git revert 恢复它

Remember, So a "revert" undoes the data changes, but it's very much not an "undo" in the sense that it doesn't undo the effects of a commit on the repository history.



我认为回答这个问题的更好人是 linus torvalds ,我找不到比他更好的人了。
Reverting a regular commit just effectively undoes what that commit
did, and is fairly straightforward. But reverting a merge commit also
undoes the _data_ that the commit changed, but it does absolutely
nothing to the effects on _history_ that the merge had.

So the merge will still exist, and it will still be seen as joining
the two branches together, and future merges will see that merge as
the last shared state - and the revert that reverted the merge brought
in will not affect that at all.

So a "revert" undoes the data changes, but it's very much _not_ an
"undo" in the sense that it doesn't undo the effects of a commit on
the repository history.

So if you think of "revert" as "undo", then you're going to always
miss this part of reverts. Yes, it undoes the data, but no, it doesn't
undo history.

一些解决 git revert 问题的链接:
  • Undo a git merge (hasn't been pushed yet)
  • git revert, reset and merge problems
  • 关于git - merge 我的分支后出现 "git revert"问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32855174/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com