如何在双重修改后继续合并

如何在双重修改后继续合并

本文介绍了如何在双重修改后继续合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 git rebase -i 来重写历史记录 - 在这种情况下,对早期提交的更改集进行小改动。换句话说,

  A --- B --- C master 

---> ;

A --- B' - C master

我知道 C 也隐含地改变了,但你明白了。这是我迄今取得的进展:


  1. git rebase -i HEAD〜2

  2. 更改 B keep 更改为编辑

  3. 编辑文件。
  4. git commit -a --amend

  5. git rebase --continue

  6. 无法应用[C] .. 。

我解决了 C 中的冲突行,不确定如何将其标记为已解决,以便继续运行。 git commit --amend 尝试修改 B ,同时 git rebase --continue 抱怨工作树很脏。 (当然, git status 显示文件为两个都修改过。)



我需要什么如何让这个rebase重新回到正轨?

解决方案

当您遇到冲突时,您应该看到类似这样的消息:

  error:could not apply 45cb26a ...< commit message subject> 
提示:在解决冲突之后,将校正后的路径标记为
hint:用'git add< paths>'并运行'git rebase --continue'



这正是您需要做的事:

 #以某种方式解决冲突
git add< conflicted-file>
git rebase --continue

请勿尝试使用提交--amend HEAD (当前提交)仍然指的是前一个,因为冲突阻止了这个提交,所以如你所见,这只是修改已经应用承诺。 rebase --continue 将继续执行包含已解决冲突的新提交。


I'm using git rebase -i to rewrite history — in this case, make a small alteration to an earlier commit's change set. In other words,

A---B---C master

      --->

A---B'--C master

I know C is implicitly changing, too, but you get the idea. Here's my progress so far:

  1. git rebase -i HEAD~2
  2. Change B from keep to edit.
  3. Edit the file.
  4. git commit -a --amend
  5. git rebase --continue
  6. "Could not apply [C]..."

I've resolved the conflicted lines in C, but am unsure how to mark it as resolved so that the rebase can continue. git commit --amend attempts to amend B, while git rebase --continue complains that the working tree is dirty. (And, sure enough, git status shows the file as "both modified".)

What do I need to do to get this rebase back on track?

解决方案

When you run into the conflicts, you should see a message something like this:

error: could not apply 45cb26a... <commit message subject>
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' and run 'git rebase --continue'

And that's exactly what you need to do:

# resolve the conflicts somehow
git add <conflicted-file>
git rebase --continue

Don't try to use commit --amend. HEAD (the current commit) still refers to the one just before, since the conflicts have prevented this commit from being made, so as you saw, that just amends the already-applied commit. rebase --continue will proceed to make the new commit containing the resolved conflicts.

这篇关于如何在双重修改后继续合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 19:57