How To Squash All Commits Of Your Feature Branch
Usually you have a lot of “intermediate” commits while developing on a feature branch like WIP
, Review changes
, Some cleanup
, Fix jenkins
. These commits are neither atomic nor does it help to read them in the history. They purely serve the purpose to persist the current work, trigger another build on your buildmachine or doing some fixes you discovered while testing. So before I rebase my changes to master I’d like to squash all commits that i’ve done to a single one. Usually I use interactive rebase for this purpose but since I need to actively tell every commit that I want to squash it I found it tedious. Also its easier, most of the time, to rebase onto master since you only apply conflicting changes to the end-result of your work without the intermediate steps you had to take. So I came up with my own git alias that solves this for me. Introducing: git squash <Commit/Branch> <Message>