Squashing
Rationale
Collapse multiple commits into one. It's usually used to tidy up the commit history.
Squashing can be achieved by interactive rebase.
git rebase -i HEAD~3
Here HEAD~3
means the 3rd ancestor of HEAD
and -i
means interactive. This will open the text editor for you decide on which commit to merge.
To cancel: git rebase --abort
To continue: Add squash
or s
at the beginning for squash, add pick
to use the commit. For example:
pick c1833a7 Commit with detached head
squash 40b2069 Apply stash on file5
s 06bcac9 Apply stash on file5
...
Another file will be open to enter the combined commit message. Then the commits labelled with s
will be squashed in the commit history.
Related
To amend previous commit:
git commit --amend -m <msg>
Last updated