Skip to main content

Squashing git commits

Introduction

Squashing is a useful trick to keep your git history short, It is also extra helpful when rebasing (as opposed to merging) Because when you rebase your rewriting git history you can to potentially resolve conflicts for EACH commit in your branch. To make rebasing cleaner you can squash your commits prior to rebasing.

How to Squashing

  • Find out the number of commits you've added since branching of main (or target branch)
  • Run `git reset --soft HEAD~<NUMBER_OF_COMMITS>