Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Squash 3 commits into 1?

I'm fairly new to git, so I've been trying to figure out how to squash 3 commits into 1 so my PR can get merged. I've read a lot of docs and guides and sort of found out how to squash commits but one of my commits aren't showing up. I tried attaching a photo of my commits and a photo of my terminal when I type in: "git rebase -i HEAD~5", but unfortunately I'm a new user so I can't? But anyway, I would greatly appreciate some help.

like image 900
Kaycee Avatar asked May 29 '17 19:05

Kaycee


People also ask

Which command will squash the last 3 commits into one commit?

Suppose we want to squash the last commits. To squash commits, run the below command: $ git rebase -i HEAD ~3.

How do I combine commits?

In case you are using the Tower Git client, using Interactive Rebase to squash some commits is very simple: just select the commits you want to combine, right-click any of them, and select the "Squash Revisions..." option from the contextual menu.


1 Answers

Squashing of commits means creation of a new commit instead of several. git reset to the base commit of your branch and make a new one. Then just git push -f to your branch.

like image 149
Raz Avatar answered Sep 25 '22 02:09

Raz