Git合并冲突 - “提交”VS“rebase --continue”

时间:2014-02-25 14:24:18

标签: git merge repository conflict

由于从项目的远程存储库中拉出来,我刚刚解决了一些冲突。

我知道,一旦冲突得到解决,据我所知,你有2个解决方案:

  • git rebase --continue
  • git commit -m "foobar"

我只是想知道这两个操作之间是否存在任何差异,仅在此背景下,因为我知道它们的基本形式根本不同?

1 个答案:

答案 0 :(得分:5)

编辑#2:

如果您使用git pull启动了此情况,则预期的解决方案是使用git commit,因为您正在创建一个新提交来表示成功合并。如果使用git pull --rebase启动了这种情况,您可能希望使用我原始答案中提到的git rebase --continue,因为这将重复使用相同的提交而不创建任何新提交。

原始答案(我认为这是以git pull --rebase开头的):

我可以告诉你,推荐的方法是使用git rebase --continue。 (见这里:http://git-scm.com/docs/git-rebase

git commit方法可能有效,但如果您不使用-C标记,则可能会更改您的提交历史记录,这是解析git merge建议的内容。我想还值得一提的是,-m标志将更改日志消息,而git rebase --continue将重用旧提交消息而不会询问。

修改

进一步的研究证实了我怀疑git commit方法是危险的,可能会使您的回购处于不良状态。看这里: http://www.tigraine.at/2011/08/10/dont-commit-when-you-rebase 在这里:Forgot "git rebase --continue" and did "git commit". How to fix?