Squash Recent Commits Without Rebasing
suggest changeIf you want to squash the previous x commits into a single one, you can use the following commands:
git reset --soft HEAD~x
git commit
Replacing x with the number of previous commits you want to be included in the squashed commit.
This creates a new commit. The previous x commits drop off the branch (author, message, and date included), but they remain in the reflog until garbage collection. Copy an existing message first if you still want it. Do this only on commits you have not pushed, or you will need to force-push.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents