Git – Squash 3 commits to one

Git Configurations

Practical example, how to make one commit after 3 pushed commits:

///new branch
git checkout -b test
//add some changes and make commit
git commit -am "first commit"
//add some changes and make commit
git commit -am "second commit"
//add some changes and make commit
git commit -am "third commit"
git push

//merge 3 last commits
git reset --soft @~3
git commit -am “merged 3 commit”
git push --force


git commit -am “first commit”

//changes

git commit -am “second commit”

//changes

git commit -am “third commit”

git push

git reset –soft @~3

git commit -am “merged commit”

git push //if was not pushed

git push –force //if was pushed

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.