[英]Force git rebase to accept my version after an initial merge conflict
Here is a git rebase/merge/continue scenario for which a more expedient approach is requested: 这是一个git rebase / merge / continue场景,需要一种更方便的方法:
Given: a file that has changes in both the present branch and the branch being rebased onto.
给定:在当前分支和要基于其分支的分支中都发生更改的文件。
Already performed: a manual merge of the files.
已执行:手动合并文件。
Complication: the following command seems to be required multiple times: it finds only a small portion of the "required" (according to git) changes to be merged at one shot:
复杂:似乎需要多次执行以下命令:它一次发现只合并了一小部分“必需”(根据git)更改:
git rebase --continue
Desired outcome: have Git simply "accept" the file that I have in the existing branch.
预期的结果:让Git简单地“接受”我在现有分支中拥有的文件。
What has been tried: after the initial
rebase
the original version of the file was copied on top of the merge conflicted version.尝试过的操作:在初始重新设置
rebase
之后,将文件的原始版本复制到合并冲突版本的顶部。What happened: after
git rebase --continue
the file is still conflicted - but with a different set of merge conflicts.发生了什么:
git rebase --continue
继续文件仍然存在冲突-但合并冲突有所不同。 This process is repeated now a few times and not done yet.现在重复此过程几次,但尚未完成。
Can we "jump to the chase" and just accept the file I updated? 我们可以“追逐”并只接受我更新的文件吗?
Take a look at git rerere
看看
git rerere
https://git-scm.com/2010/03/08/rerere.html https://git-scm.com/2010/03/08/rerere.html
Here's the gist (taken from that article): 这是要点(摘自该文章):
The name stands for "reuse recorded resolution" and as the name implies, it allows you to ask Git to remember how you've resolved a hunk conflict so that the next time it sees the same conflict, Git can automatically resolve it for you.
该名称代表“重用记录的分辨率”,顾名思义,它使您可以要求Git记住您如何解决了一次大冲突,以便下次遇到相同的冲突时,Git可以自动为您解决。
The reason you have multiple conflicts is that you're rebasing multiple commits, with several (all?) of them consisting conflicting changes to the file. 发生多个冲突的原因是您要重新建立多个提交,其中几个(全部?)包含对文件的冲突更改。 You can't skip these conflict resolution steps since you're creating multiple new commits and each requires a specific version of the file, in a resolved state.
您无法跳过这些冲突解决步骤,因为您正在创建多个新提交,并且每个提交都需要文件的特定版本(处于已解决状态)。
You can either continue like before, or you can choose to squash your commits and by that avoid the need to generate multiple commits and only merge once. 您可以像以前一样继续操作,也可以选择压缩提交内容,这样就无需生成多个提交内容并且仅合并一次。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.