3

Let's say that I have the following three commits:

c - Third Commit
b - Second Commit
a - First Commit

I use the following commands to perform the interactive rebase (as described in another StackOverflow thread)

$ git rebase --interactive bbc643cd^

In the default editor, modify 'pick' to 'edit' in the line whose commit you want to modify. Make your changes and then commit them with the same message you had before:

$ git commit --all --amend --no-edit

to modify the commit, and after that

$ git rebase --continue

The problem is that sometimes, when I'm done, the commits have been squished into one single commit (the oldest commit, a in my example).

It seems that it may have something to do with when there are merge conflicts to resolve, so I suspect I may be continuing incorrectly after resolving. After resolving merge conflicts, I'm unsure about whether I need to simply do git rebase --continue or both $ git commit --all --amend --no-edit AND git rebase --continue. It seems like in both cases, I've had merged commits at the end, but I'm not sure.

What am I doing wrong?

Community
  • 1
  • 1
Pete
  • 7,289
  • 10
  • 39
  • 63
  • If I am not mistaken, if you `commit --amend` after resolving conflicts by hand you are amending the *preceding* commit. – Tobia Tesan Sep 22 '15 at 18:50

1 Answers1

4

Indeed as Tobia Tesan said in the comment, the --amend option adds the files to the last commit instead of creating a new one.

It should work good if you drop this option.

Bartlomiej Lewandowski
  • 10,771
  • 14
  • 44
  • 75
  • So I should do everything the same, except AFTER resolving merge conflicts, I should do: `git commit --all --no-edit` and `git rebase --continue`? – Pete Sep 22 '15 at 19:35