Things can accumulate over time, and version control systems can be subject to the same hoarding tendencies that haunt people in the everyday aspects of their lives. Gut there comes a point where you need to do a Git clean up. Branches, commits and repositories require a good trim from time to time. In this Git clean up tutorial, I’ll demonstrate how to take a moderately messy repository and reduce it down to only a few commits.

git squash commit branches

These commits and branches will be the target of the Git clean up.

The first order of business with any Git clean up operation is to squash any lengthy commit histories. In this example, there is only one commit on the master branch, but multiple on feature and develop branches. This requires the use of the interactive rebase tool to squash all commits on a branch down to one.

Clean up Git commits

To squash commits on the develop branch, first perform a checkout and then issue the…



News Source