4

I usually never do this but this time I wound up with a feature branch that, for update purposes, got master merged into it (I usually favour rebase master on my feature branch to avoid useless merge commits).

And now I want to squash all commits of my feature branch into one before merging it as finalised to master but it is not as seamless as it usually is.

How can I do that?

C-Otto
  • 5,615
  • 3
  • 29
  • 62
ptpdlc
  • 2,373
  • 6
  • 22
  • 33
  • 1
    https://stackoverflow.com/questions/6248231/git-rebase-after-previous-git-merge – C-Otto Jan 23 '18 at 08:26
  • 1
    Possible duplicate of [Interactive rebase after merging/other commits interleaving mine](https://stackoverflow.com/questions/32826197/interactive-rebase-after-merging-other-commits-interleaving-mine) – C-Otto Jan 23 '18 at 08:27
  • 1
    https://stackoverflow.com/questions/24174055/git-rebase-after-merge – C-Otto Jan 23 '18 at 08:27
  • Do you want to preserve the merge commit with `master`? – Tim Biegeleisen Jan 23 '18 at 08:30
  • Possible duplicate of [git rebase after previous git merge](https://stackoverflow.com/questions/6248231/git-rebase-after-previous-git-merge) – phd Jan 23 '18 at 12:30

1 Answers1

0

Simplest way would be to merge all the changes as single commit using merge --squash

git checkout master
git merge --squash feature_branch
git commit -a

Note: However, this doesn't really do a merge. It is more akin to doing a single commit on master itself. That's why I always mention the name of the merged branch explicitly in commit message.

hspandher
  • 15,934
  • 2
  • 32
  • 45