Git Squash Commits
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.
Squashing is easier when you’re able to clearly see all of your commits listed listed in order in GitKraken’s central graph. Try an easier way to squash commits ⬇️
Can you Git squash all commits in a branch?
Yes, you can Git squash commits multiple times on the same branch to go from many commits down to one commit.
Without the visual context offered by GitKraken, squashing all of the commits in a branch can be complex in the CLI. GitKraken gives you more control when performing advanced Git actions.
How to Git Squash Commits in GitKraken
In order to have the ability to Git squash commits in GitKraken, the following criteria must be met:
- You have more than one commit selected
- The youngest commit is also the current HEAD
- Your commits are genealogically consecutive (i.e. parent, child, parent, child)
- Your commits are chronologically consecutive
- The oldest commit in your selection needs to have a parent
If all of the above conditions are met, you will see an option to Git squash commits by right-clicking on the commit node after selecting the commits you wish to squash.
Git Squash 2 Commits
In GitKraken, you can multi-select consecutive commits from the central graph to Git squash 2 commits, or more, at the same time. Select one commit from the graph and hit and hold the Shift button before selecting the other commits.
Easy as that! You are now a master of squashing commits using the legendary GitKraken Git GUI!