gpt4 book ai didi

git - 在 Git 中重新进行还原 merge

转载 作者:IT王子 更新时间:2023-10-29 01:15:31 25 4
gpt4 key购买 nike

我在这里遇到了一些问题:我在 Git 中有一个特定于问题的分支 28s,我将其 merge 到一般的 develop 分支中。原来我做得太快了,所以我使用 git-revert 来撤消 merge 。然而,现在是时候将 28s merge 到 develop 中了,但是 git-merge 命令看到了原始 merge ,并高兴地宣布一切都很好,分支已经完成 merge 。现在我该怎么做?创建一个“还原”还原“28s -> 开发””'提交?这似乎不是一个好方法,但我目前无法想象任何其他方法。

树结构是什么样子的:

Git log output

最佳答案

你必须“还原还原”。根据您如何还原原始文件,它可能不像听起来那么容易。看official document on this topic .

---o---o---o---M---x---x---W---x---Y
/
---A---B-------------------C---D

允许:

---o---o---o---M---x---x-------x-------*
/ /
---A---B-------------------C---D

But does it all work? Sure it does. You can revert a merge, and from a purely technical angle, git did it very naturally and had no real troubles.
It just considered it a change from "state before merge" to "state after merge", and that was it.
Nothing complicated, nothing odd, nothing really dangerous. Git will do it without even thinking about it.

So from a technical angle, there's nothing wrong with reverting a merge, but from a workflow angle it's something that you generally should try to avoid.

If at all possible, for example, if you find a problem that got merged into the main tree, rather than revert the merge, try really hard to:

  • bisect the problem down into the branch you merged, and just fix it,
  • or try to revert the individual commit that caused it.

Yes, it's more complex, and no, it's not always going to work (sometimes the answer is: "oops, I really shouldn't have merged it, because it wasn't ready yet, and I really need to undo all of the merge"). So then you really should revert the merge, but when you want to re-do the merge, you now need to do it by reverting the revert.

关于git - 在 Git 中重新进行还原 merge ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1078146/

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