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



我使用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. "Could not apply [C]…"

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

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

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

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将继续创建包含解决冲突的新提交。

您是否尝试过明确地执行此操作,即:先执行git add B',然后提交--amend,然后执行git rebase --continue ?

最新更新