Monday, May 30, 2022

Git - Squash

Git Squash commit

 To squash in Git means to combine multiple commits into one. You can do this at any point in time (by using Git's "Interactive Rebase" feature), though it is most often done when merging branches.

Please note that there is no such thing as a stand-alone git squash command. Instead, squashing is rather an option when performing other Git commands like interactive rebase or merge.

Squash using interactive rebase

In the below example, the last 3 commits are combined into one commit using git-rebase.

  •    touch
  •    git status
  •    touch
  •    touch
  •    git add .
  •    git commit -m ""
  •    git commit -m ""
  •    git commit -m ""
  •    git log --oneline
  •    git rebase -i HEAD~3

change pick to squash

rewrite the commit history by adding # infront of and


Post a Comment