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

Ben*_*ank 8 git conflict rebase

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

A---B---C master

      --->

A---B'--C master
Run Code Online (Sandbox Code Playgroud)

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

  1. git rebase -i HEAD~2
  2. 改变Bkeepedit.
  3. 编辑文件.
  4. git commit -a --amend
  5. git rebase --continue
  6. "无法申请[C] ..."

我已经解决了冲突的行C,但不确定如何将其标记为已解决,以便rebase可以继续. git commit --amend尝试修改B,同时git rebase --continue抱怨工作树很脏.(而且,当然,git status将文件显示为"已修改".)

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

Cas*_*bel 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'
Run Code Online (Sandbox Code Playgroud)

这正是你需要做的:

# resolve the conflicts somehow
git add <conflicted-file>
git rebase --continue
Run Code Online (Sandbox Code Playgroud)

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

  • @Ben:这是一个很容易错过的人,因为只要你知道自己在做什么,你就会立即解决冲突,忘掉那里的一切. (2认同)