18

I rebase another branch onto my checkout branch and I get a conflict during rebase. i resolved the merge conflict.

$ git status
rebase in progress; onto 77c951b
You are currently rebasing branch 'test' on '77c951b'.
  (all conflicts fixed: run "git rebase --continue")

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   br_boss_buha_faktura/forms/br_boss_buha_faktura_head_dtl.frm
        modified:   br_boss_buha_faktura/valuelists/br_boss_buha_faktura_client.val
        new file:   br_boss_buha_faktura/valuelists/br_boss_buha_faktura_client_name.val

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   br_boss_buha_faktura/valuelists/br_boss_buha_faktura_client.val

Do I need to commit the above resolved merge conflict git commit or can I directly go further using git rebase --continue?

gavv
  • 4,649
  • 1
  • 23
  • 40
BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96

4 Answers4

22

Some good answers here but to answer the question. NO you do not need to commit after resolving the merge conflict.

Once you have added the resolution to the git staging area via git add <file> a git rebase --continue will make the commit for you using the original commit message.

NOTE the commit hash will change! So when you go to merge this into another branch that has commits that you altered in your branch you will have issues merging those branches together.


NOTE I said you do not need to git commit after resolving a git rebase conflict, but you can if you want to.

It may be useful to split files from one commit into a series of individual commits if it makes more sense. Usually you just want to resolve the conflict though. As is shown here: Break a previous commit into multiple commits.

Breedly
  • 12,838
  • 13
  • 59
  • 83
  • 2
    So you don't _need to_. Okay. It would be nice if your answer also explained what would happen if you _did_ commit before continuing the rebase. – init_js Jun 01 '20 at 16:30
4

Here I see

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   br_boss_buha_faktura/valuelists/br_boss_buha_faktura_client.val

Please do

git add br_boss_buha_faktura/valuelists/br_boss_buha_faktura_client.val

Then

git rebase --continue
Gopi
  • 19,784
  • 4
  • 24
  • 36
  • 1
    After `git add`, is `git commit -a` is really needed? – BuZZ-dEE Sep 30 '14 at 08:05
  • Yeah please do git commit -a – Gopi Sep 30 '14 at 08:20
  • Could you please explain, why I need to do a commit, because I found a [thread here, which explains the opposite](http://stackoverflow.com/a/3611293/183704)? – BuZZ-dEE Sep 30 '14 at 08:34
  • How many commits you have in your topic_branch matters. Let's say you have a single commit then you can resolve the conflicts and do git add and git commit.If there are more than 1 commits then you should do a git rebase --continue . Even if you have a single commit you can do git rebase --continue(safer) – Gopi Sep 30 '14 at 08:49
  • This does not really answer my question. – BuZZ-dEE Sep 30 '14 at 08:52
  • Please let me know how was your repo before you started the rebase. Let me presume you had made some changes to some files and had done a commit for the same. Later when you tried to rebase you got conflicts. So the solution would be to resolve the conflicts and add them to notify that the conflicts has been resolved and followed by it do git rebase --continue – Gopi Sep 30 '14 at 09:10
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/62166/discussion-between-pala-and-buzz-dee). – Gopi Sep 30 '14 at 09:19
  • I would never advise use of the `-a` option, especially not to `git commit`: It is basically asking for mistakes to happen ("Oh, you just published all your '.o' files - looks like a very smart thing to do..."). Better use `git status` and add what you really want to add. – cmaster - reinstate monica Jul 26 '16 at 16:28
1

Doing a git rebase --continue will rewrite the current commit you are applying to the form you changed it to. It will commit the changes under the same name you had in the test branch.

Note you are rebasing on a commit, might be a detached HEAD state! Usually, one rebases on master or a staging branch.

rubenvb
  • 74,642
  • 33
  • 187
  • 332
  • So I do not need to use `git commit`? I fix it and then I just use `git rebase --continue`? What do you mean with "Usually, one rebases on master or a staging branch."? I'm on branch `test` and have done a `git rebase featureA` onto the `test`branch. – BuZZ-dEE Sep 30 '14 at 07:43
  • Yes, just as [the documentation tells you to](http://git-scm.com/docs/git-rebase). Also, as @pala said, you have one file that is not staged to commit. Is that the intention or should it be part of the current rebase commit? – rubenvb Sep 30 '14 at 08:58
  • Yes, I figured out, that I have to add the file `git add br_boss_buha_faktura/valuelists/br_boss_buha_faktura_client.val`, because `git rebase --continue` does not work and I get the message `You must edit all merge conflicts and then mark them as resolved using git add`. – BuZZ-dEE Sep 30 '14 at 09:29
1

If you DO commit your changes, I believe that you can do a git rebase --skip to skip over the now non-existent merge conflict.

John B
  • 20,062
  • 35
  • 120
  • 170