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

时间:2011-04-17 23:28:25

标签: git conflict rebase

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

A---B---C master

      --->

A---B'--C master

我知道C也在隐式改变,但你明白了。到目前为止,这是我的进展:

  1. git rebase -i HEAD~2
  2. Bkeep更改为edit
  3. 编辑文件。
  4. git commit -a --amend
  5. git rebase --continue
  6. “无法申请[C] ...”
  7. 我已经解决了C中存在冲突的行,但我不确定如何将其标记为已解决,以便可以继续使用rebase。 git commit --amend尝试修改B,而git rebase --continue则抱怨工作树很脏。 (当然,git status将文件显示为“已修改”。)

    我需要做些什么才能让这个rebase回到正轨?

2 个答案:

答案 0 :(得分:10)

当您遇到冲突时,您应该会看到如下消息:

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'

这正是你需要做的事情:

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

请勿尝试使用commit --amendHEAD(当前提交)仍然引用之前的那个,因为冲突阻止了这个提交,正如你所看到的那样,只是修改了已经应用的提交。 rebase --continue将继续进行包含已解决冲突的新提交。

答案 1 :(得分:1)

您是否已尝试明确地执行此操作,即:git add B',然后将其与--amend一起提交,然后执行git rebase --continue