To squash multiple commits, I have always used:
git reset --soft HEAD~<number of commits to squash> && git commit
But I wonder if there is a good way to do this in a good git client like git extensions? It would be cool if you could just select consecutive commits and squash them.
Before you start, keep in mind that you should squash your commits BEFORE you ever push your changes to a remote repository. If you rewrite your history once others have made changes to it, you're asking for trouble… or conflicts.
What does it mean to squash commits in Git? Squashing is a way to rewrite your commit history; this action helps to clean up and simplify your commit history before sharing your work with team members. Squashing a commit in Git means that you are taking the changes from one commit and adding them to the Parent Commit.
There are multiple ways of doing a squash.
Here's how you can easily squash the current and all its immediate parent commits into a single commit in Git Extensions:
Here's an animation of the above:
Another way is to do an "interactive rebase" either
git rebase -i
, read docs), orTo do an interactive rebase in Git Extensions:
Here's an animation of the above:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With