3

I just finished resolving some conflicts due to a pull from the remote repository of my project.

I know that once conflicts have been resolved you have, to my knowledge, 2 solutions :

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

I was just wondering if there are any differences between those 2 operations, in this context only, as I know they are fundamentally different in their basic form ?

Mickäel A.
  • 9,012
  • 5
  • 54
  • 71

1 Answers1

7

EDIT #2:

If you initiated this situation with git pull, the expected resolution is to use git commit, because you are creating a new commit to represent the successful merge. If this situation was initiated with git pull --rebase, you would want to use git rebase --continue as mentioned in my original answer, as this will reuse the same commits without creating any new ones.

Original answer (in which I assumed this was initiated with git pull --rebase):

I can tell you that the recommended method is to use git rebase --continue. (See here: http://git-scm.com/docs/git-rebase)

The git commit method may work, but it may change your commit history if you don't use the -C flag, which is what resolving a git merge will recommend. I suppose it is also worth mentioning that the -m flag will change the log message, whereas the git rebase --continue will reuse the old commit message without asking.

EDIT:

Further research confirms my suspicions that the git commit method is dangerous and may leave your repo in an undesirable state. See here: http://www.tigraine.at/2011/08/10/dont-commit-when-you-rebase and here: Forgot "git rebase --continue" and did "git commit". How to fix?

Community
  • 1
  • 1
pattivacek
  • 5,617
  • 5
  • 48
  • 62
  • The problem is that the official Git user guide tells to commit after resolving conflicts (last sentence) : http://git-scm.com/book/en/Git-Branching-Basic-Branching-and-Merging – Mickäel A. Feb 25 '14 at 14:42
  • That page relates to merging. Rebasing is a different operation even though it might seem similar. – pattivacek Feb 25 '14 at 14:43
  • Pull is fetch + merge. So my problem is related to merging, not rebasing, even if this command is used to end the merge. – Mickäel A. Feb 25 '14 at 15:10
  • So wait, did you initiate all of this with `git pull` or `git pull --rebase`? I assumed it was the latter, since you mentioned using the `git rebase --continue` command, but if you started with a `merge`, you definitely don't want to use any `rebase` commands! – pattivacek Feb 25 '14 at 15:19
  • I used `git pull`, but anyway `git rebase --continue` also works, which is kind of weird. That's why I posted. – Mickäel A. Feb 25 '14 at 15:21
  • During a `merge`, `git rebase --continue` should not be an option. I just simulated this sequence of events and I get an error: `No rebase in progress?` If it does somehow work for you, I would not recommend it at all. I will amend my answer. – pattivacek Feb 25 '14 at 15:26
  • Indeed it was just mistake I did. Thanks ! – Mickäel A. Feb 25 '14 at 15:38