Search code examples
gittortoisegitsquash

How to squash non-sequential commits


I have a feature branch that I've been doing work on and committing at save points along the way. During this process, I had to merge the develop branch into my feature branch to pick up some bug fixes that another developer did. So my commit history looks something like this:

  • In progress #4
  • In progress #3
  • Merge develop into feature branch
  • In progress #2
  • In progress #1
  • etc...

I want to squash all of the "In progress" commits but leave the merge commit in place. How can I do that using either command line or TortoiseGit?


Solution

  • As mentiones in the comment, you can do a git rebase with preserve merges option. And then reorder the commits and squash them