Squashing Commits in Middle
Last updated
Last updated
If the commits to be squahed are not the last few commits, an interactive rebase is needed. Similar to how we reword commits in middle, we start an interactive rebase, but this time instead of reword
, we change the pick
to s
or squash
for the second commit meaning squash the second up into the first commit.
After saved and closed the Editor, Git then will popup the Editor asking for the new commit message of the squashed commits.
We now need to replace the WIP: Fix blah blah
with a new commit message Fix blahblah
and remove the WIP: Continue Fix blah blah
.
Once finished it looks like below (I created a before_rebase
branch so we can see it more clearly):
The fixup
option: fixup
is very similar to squash
except that fixup
uses the commit message of the first commit whereas squash
requires a new commit message.