简体   繁体   English

解决git rebase期间的冲突

[英]Resolving conflicts during git rebase

For the sake of simplicity, imagine following case: 为简单起见,想象一下以下情况:

      D---E---F--- ... ---Z  topic
     /
A---B---C                    master

I'd like to rebase on master, so that the D to Z "chain" is after C , however, all the D , E , F , ..., Z commits creates a conflicts when rebasing them 1 by 1. Let's just say that each of them has a conflict on a different line with commit C . 我想在master上进行rebase,以便DZ “链”在C之后,然而,所有DEF ,..., Z提交在将它们1乘以1时会产生冲突。让我们只是假设他们每个人在提交C的不同行上都存在冲突。

I'd like to resolve all those conflict at once and not in the rebase interactive mode ( --continue, --abort, --skip ), or what ever it is. 我想立刻解决所有这些冲突,而不是在rebase交互模式( --continue, --abort, --skip )或者它是什么。 My question is whether it's totally bad to ignore the conflicts and do the conflict resolution at the very end. 我的问题是,忽视冲突并在最后解决冲突是否是完全不好的。 By a new explicit commit or in the last rebase step. 通过新的显式提交或最后一个rebase步骤。

By ingoring I mean: git add -A && git commit 通过ingoring我的意思是: git add -A && git commit

This will lead to the history where some commits contain the code-base in the state that's not working, right? 这将导致一些提交包含处于不工作状态的代码库的历史,对吧?

ps. PS。 I don't wan't to be merging, I'd like to rebase. 我不想合并,我想改变。

Yes, it is a bad idea to ignore conflicts reported by Git. 是的,忽略Git报告的冲突是个坏主意。 The logical change from C to D is not likely to be achieved by the same code change between B and D . CD的逻辑变化不可能通过BD之间的相同代码变化来实现。 If it were simple enough, then Git would not have asked for intervention. 如果它足够简单,那么Git就不会要求干预。 If you don't care about history, you could combine all the D to Z commits into one and then try to rebase. 如果您不关心历史,可以将所有DZ提交合并为一个,然后尝试重新绑定。

You have the git rerere command for your help. 你有git rerere命令来帮助你。

git rerere

R ecorded R eused R esolution řecordedřeusedřesolution

# enabled the option to record the 
git config --global rerere.enabled true

By the way, if you prefer rerere to auto-stage files it solved (I do), you can ask it to: you just need to tweak your configuration like so: 顺便说一句,如果您更喜欢rerere自动暂存它解决的文件(我这样做),您可以问它:您只需调整您的配置,如下所示:

git config --global rerere.autoupdate true

在此输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM