如何在rebase期间解决冲突?

时间:2014-01-06 10:51:20

标签: git

我有两个分支:

  $ git branch
    master
  * readcode

我对master做了一些更改,所以我想将更改带到readcode分支。然后我使用了rebase:

$ git rebase master
First, rewinding head to replay your work on top of it...
Applying: Health score enhancement.
Using index info to reconstruct a base tree...
Falling back to patching base and 3-way merge...
Auto-merging file1
CONFLICT (content): Merge conflict in file1
Failed to merge in the changes.
Patch failed at 0001 Health score enhancement.

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

file1中,有几行冲突。我在编辑器中修复了file1中的冲突。但我发现我现在不在readcode分支:

$ git branch
* (no branch)
  master
  readcode

但我仍然按照提示信息进行操作:

$ git rebase --continue
file1: needs merge
You must edit all merge conflicts and then
mark them as resolved using git add

然后使用git add并再次继续:

$ git add lib/nimbus/loadbalancer/lb.rb
$ git rebase --continue
Applying: Health score enhancement.
No changes - did you forget to use 'git add'?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this patch.

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To restore the original branch and stop rebasing run "git rebase --abort".

我应该用哪个命令告诉git我已经解决了冲突,并继续使用rebase?

2 个答案:

答案 0 :(得分:1)

您是否阅读了错误消息发布的输出?它清楚地表明你应该使用

git rebase --continue

答案 1 :(得分:0)

我最近也遇到过这个问题 原因可能是您删除了在冲突解决期间提交的所有更改。

所以git认为 没有变化 ,并且没有必要生成 补丁

所以建议使用git rebase --skip,结果是你的提交导致冲突被丢弃

您可以在本地重现问题