Git

Last Updated: 9/5/2023

Squash Merging

  • We're going to create a new commit that combines all the changes in the bug fix branch. So we have a single logical chain set that represents all the changes for fixing this bug. Now we can apply this commit on top of master. This is what we call squash merging.
  • The new commit is not a merge commit. Because it doesn't have two parents, it doesn't have a reference to bugfix branch, it's just a regular commit that we have added on top of master.
  • This technique should not be used all the time, you should use it with small, short lived branches with bad history, like bug fixes or features that you can implement in a few hours or in a day.
git switch master
git merge --squash branchname
git commit -m "Fixed the bug"

Delete unmerged branch

git branch -D branchname

-D: enforce deletion