将“放弃所有更改"还原为“放弃所有更改".合并效果 [英] Reverting "discard all changes" merge effect

查看:246
本文介绍了将“放弃所有更改"还原为“放弃所有更改".合并效果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

让我们假设它是通过放弃合并中的所有更改..."选项进行合并的,这是偶然的.

Let's suppose it was performed merge with "Discard all changes from merge ..." option, bu accident.

此错误的提交已提交到中央"存储库中.

And this wrong commit has been committed into the "central" repository.

如果我需要以分支更改的正确方式合并,该如何处理?

How to deal with this case if I need to merge in correct way the branch changes?

重现案例的命令:

hg init mr
cd mr

echo "123" > file.txt
hg add
hg ci -m "initial"

hg branch br
echo "234" >> file.txt
hg ci -m "in branch"

hg up default
echo "567" >> file.txt
hg ci -m "in default"

在这些命令之后打开tortoisehg,然后将第二版(默认标头)与br分支合并,并使用放弃..."选项.

After these commands open tortoisehg, and merge 2nd revision (default head) with br branch with "Discard ..." option.

UPD :

这是关于执行相反的

It is a question about doing the opposite How to merge to get rid of head with Mercurial command line, like I can do with TortoiseHg? ;-)

但是仍然找不到如何恢复该步骤的方法:-(

But still cannot find how to revert that step :-(

推荐答案

一种方法是重做合并,然后使用丢弃进行另一次合并.

One way would be to redo the merge, and do yet another merge with discard.

在您的示例中,更新回到第二个修订版(在进行错误合并之前,当前工作目录是父目录),然后与该另一个分支重做合并.这次正确地做.

In your example, update back to the 2nd revision (the current working directory parent before you did the bad merge), then redo the merge with that other branch. Do it properly this time.

这会给你另一个头.

然后,与不正确的旧合并合并,并选择丢弃.现在,您已经有效地绕过了正确的合并.

Then, merge with the old, incorrect merge, and choose discard on this. Now you have effectively bypassed this merge with a correct one.

如果不确定步骤,进行本地克隆并进行实验,则始终可以将其丢弃并重新克隆,然后重试.

If you're unsure about the steps, make a local clone and experiment, you can always just discard it and reclone and try again.

修订版3是旧的,错误的合并,在这里我选择了放弃.完成合并4和5之后,该合并的痕迹消失了,一切恢复正常.是的,历史记录看起来有些时髦,但是请相信我,彻底摆脱不良合并的清理程序远比历史记录时间表上的小问题还差.

Revision 3 is the old, incorrect merge, where I chose discard. After doing merge 4 and 5, the traces of that merge is gone and everything is back in working order. Yes, the history looks a little funky, but trust me, the cleanup procedures to get rid of that bad merge completely is far worse than the little hickup on your history timeline.

基本上,合并后,您会遇到以下情况:

Basically you have this scenario after the botched merge:

            +-- botched merge
            v
    0---2---3
     \     /
      1---+

因此,您这次更新回错误合并之前的工作文件夹父文件夹,并再次进行合并.现在看起来像这样:

So you update back to the working folder parent you had before the bad merge, and do another merge, this time properly. Now it looks like this:

            +-- botched merge
            v
    0---2---3
     \   \ /
      \   x
       1-+-4
           ^
           +-- good merge

您的工作文件夹现在处于版本4,因此您又进行了一次合并,这次是版本3(不良合并),然后选择放弃这些更改,您将得到:

Your working folder is now at revision 4, so you do yet another merge, this time with revision 3 (the bad merge), and choose to discard those changes, and you get this:

            +-- botched merge
            v
    0---2---3-5  <-- final merge, discard 3
     \   \ / /
      \   x /
       1-+-4
           ^
           +-- good merge

TortoiseHg的显示方式如下:

Here's how TortoiseHg shows this:

这篇关于将“放弃所有更改"还原为“放弃所有更改".合并效果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆