撤消在 rebase 中完成的 git rerere 解析

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18500016/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 08:58:11  来源:igfitidea点击:

Undo a git rerere resolution that was done in a rebase

gitgit-rebasegit-rerere

提问by kevinmm

Okay, so I really like the git rerere command. Although, I haven't really used it that much other than letting it auto-magically record my conflicts and resolve them for me. However, I did mess up one of my conflict resolutions during quite a large rebase (rebasing a really stale feature branch with the latest release).

好的,所以我真的很喜欢 git rerere 命令。虽然,除了让它自动神奇地记录我的冲突并为我解决它们之外,我并没有真正使用它。但是,我确实在相当大的变基期间搞砸了我的一个冲突解决方案(用最新版本对一个非常陈旧的功能分支进行变基)。

feature -> a - b - c - d

release -> e - f - g - h

rebase/feature -> e - f - g - h - a' - b' - c' - d'

So, say for instance that b' has an incorrect merge (thanks to me!), and I want to re-record that. How would I do it? I've seen the git checkout --conflict option, mentioned in Rerere Your Boat, but I'm not too clear on how that works and if it applies here. Maybe I have to checkout the merge conflict state and run git rerere once I correctly resolve this conflict?

因此,例如说 b' 的合并不正确(感谢我!),我想重新记录它。我该怎么做?我看过Rerere Your Boat 中提到的 git checkout --conflict 选项,但我不太清楚它是如何工作的以及它是否适用于这里。也许我必须检查合并冲突状态并在正确解决此冲突后运行 git rerere ?

Normally, I would just commit to the tip of the rebase branch, but it is a throw away. I'm just trying to handle conflicts ahead of time, so that when I sync up with that feature team, we minimize the time it takes. Make sense?

通常,我只会提交 rebase 分支的尖端,但它被扔掉了。我只是想提前处理冲突,这样当我与该功能团队同步时,我们可以最大限度地减少所需的时间。有道理?

回答by Colin D Bennett

To simply remove all previous rerereresolutions, run rm -rf .git/rr-cacheto remove the cache.

要简单地删除所有以前的rerere分辨率,请运行rm -rf .git/rr-cache以删除缓存。

For a specific merge, you can tell rerereto forget the recorded resolution by re-executing the merge and allowing rerereto apply its recorded resolution in the work tree.

对于特定的合并,您可以rerere通过重新执行合并并允许rerere在工作树中应用其记录的分辨率来告诉忘记记录的分辨率。

You can check out a'and then do a git merge bto get back into that situation (you'll probably be in a checkout of a detached head since you specified the commit hash of a', so be aware that you're not on a branch).

您可以检出a'然后执行 agit merge b以回到那种情况(因为您指定了 的提交哈希a',所以您可能会处于分离头的检出状态,因此请注意您不在分支上)。

Then use git rerere forget FILE-WITH-BAD-MERGEwhere to specify the file whose recorded conflict resolution should be forgetten.

然后使用git rerere forget FILE-WITH-BAD-MERGEwhere 指定应该忘记其记录的冲突解决方案的文件。

forget <pathspec>
Reset the conflict resolutions which rerere has recorded for the current conflict in .

forget <pathspec>
重置 rerere 为当前冲突记录的冲突解决方案。

(From the Git documentation for git-rerere.)

(来自git-rerere 的 Git 文档。)