How can I continue merging after a double-modify?

∥☆過路亽.° 提交于 2020-01-02 02:40:13

问题


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?


回答1:


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.




回答2:


Have you tried doing it explicitly, i.e.: git add B', then committing it with --amend, then doing git rebase --continue?



来源:https://stackoverflow.com/questions/5697184/how-can-i-continue-merging-after-a-double-modify

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!