You could do it this way:
git reset --soft HEAD~20
git commit -m "massive commit"
- The first command moves your topic branch 20 commits back, but preserves the changes in the index (and the working tree)
- Then you create a single commit with all the changes.
A quick way to find the exact commit you want to reset to is to do
git merge-base <topicbranch> <otherbranch>
If the output of that is <commit-ish>
, you can then do
git reset --soft <commit-ish>