Squash Recent Commits Without Rebasing

suggest change

If 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.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents