How To Squash Commits?
The below image shows we have 3 commits: Initial commit, Commit 2, and Version 1 Release. We’ve successfully released the 1st version (R_V1) of the GFG_VIDEO tool. After R_V1 new features are added and minor bugs are fixed from the previous release and the tool is ready for its 2nd release R_V2.
The above image of the GFG_VIDEO log is after the 2nd version release. It can be observed after the Version 1 Release (tag: R_V1) there are 3 commits for the Version 2 Release. This kind of looks untidy, to make it simpler to read we can do a squash operation.
Let’s perform squash now
git rebase -i HEAD~3
Note: Rebase is an action to rewrite commits and their history “-i” is to enter into an interactive mode of rebase HEAD~n states to perform our operation on n commits from HEAD.
Contact Us