Squash multiple commits into one

Pre­ma­ture com­mits hap­pen all the time. And often you want to squash all those pre­ma­ture com­mit into one mean­ing­ful com­mit  to keep your com­mit his­tory clean, eas­ily read­able and more mean­ing­ful. It’s quite easy to squash as many com­mits as you want using fol­low­ing commands

In this exam­ple, git reset --soft resets the HEAD to the pro­vided com­mit num­ber. And adds all the changed files into the stag­ging area then you can cre­ate one mean­ing­ful com­mit mes­sage 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 *