Git Squashing Squash Recent Commits Without Rebasing

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

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.

Mind that this will create a new commit, essentially forgetting information about the previous x commits including their author, message and date. You probably want to first copy-paste an existing commit message.



Got any Git Question?