DEV Community

loading...

How to Squash 3 commits into 1?

ajay upreti
A passionate Software Developer 🚀 having an experience of building Web applications. Have experience working in a startup.
・1 min read

Do git log and see the commits you want to squash is commited first.

if you want squash top 3 commits from your head,
Use this command,

git rebase -i HEAD~3

Here the tilde ~ symbol with 3 pick the top latest three commits and it will pop up in an interactive shell where you can select the top commit and squash other two commits into one by entering s, it means squash.

If your commit is not appearing then do git log and see, if not then

git add files
git commit -m 'your commit'

Discussion (1)

Collapse
kigster profile image
Konstantin Gredeskoul

Or, install Bashmatic:

bash -c "$(curl -fsSL https://bashmatic.re1.re); bashmatic-install -q"
source ~/.bashmatic/init.bash

# and use git.squash function:
git.squash 3
Enter fullscreen mode Exit fullscreen mode