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.
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…