Vojtěch
Vojtěch

Reputation: 12416

git has problems with squashing commits once there is "Merge branch"

I am trying to squash some commits – current git log looks like this:

https://gist.github.com/knyttl/a2f39cd9376301c78b07

Notice the "merge branch 'master'" – once this shows in the log, the squashing rebase always results in conflicts.

git rebase -i ZZZZZZ

What I don't understand that this branch has all conflicts resolved, every commit is nicely in the line, so why should these problems emerge?

[detached HEAD YYYYY] Typo
16 files changed, 192 insertions(+), 83 deletions(-)
error: could not apply XXXX... Typo

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

Could not apply XXXX... Typo

I just want simply all those commits to disappear and create one instead of all of them.

Upvotes: 0

Views: 452

Answers (2)

Vojtěch
Vojtěch

Reputation: 12416

I found the answer for what I really wanted – in fact I was just looking for:

git reset --soft ZZZ
git commit -a -m "Message for the merged commit."

This way I can merge the commits without any necessity for conflict resolving.

Upvotes: 1

Franck
Franck

Reputation: 1394

Do you still the branch you merge ?

You can git reset --hard _hash-before-merge_

then

git merge --squash your-branch
git commit

that should squash all of your commits into one and the do the merge.

Upvotes: 0

Related Questions