When your git commit history gets long in the tooth, and you want to clean up your feature and topic branches before the merge to master, you’ll need the facilities of the Git squash commit feature.

git squash commit branches

This git squash commits example begins with three active branches.

In this example of how to squash git commits, the repository I’m using has three Git Flow compatible branches:

  • master with one unmerged commit
  • develop with five unmerged commits
  • feature with three unmerged commits

Through the use of Git’s interactive rebase feature, I will squash both the develop and feature branches down to one commit. A post-squash merge will then bring both develop and feature branches into master.

Git’s squash commits command

There is no explicit Git squash command. Instead, to squash git commits, the interactive git rebase is used.

To squash all commits on a single branch, the interactive git rebase command must be passed one of two arguments:

  • the id of the…



News Source