Squash multiple commits into one

Premature commits happen all the time. And often you want to squash all those premature commit into one meaningful commit  to keep your commit history clean, easily readable and more meaningful. It’s quite easy to squash as many commits as you want using following commands

In this example, git reset --soft resets the HEAD to the provided commit number. And adds all the changed files into the stagging area then you can create one meaningful commit message for all the changed files. If you have not pushed your changes to remote in the past you do not have to use --force flag.

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *