This can be done easily without git rebase
or git merge --squash
. In this example, let's squash the last 2 commits.
git reset --soft HEAD~2
The 2
above points at the last 2 commit counting from the HEAD which is the top most commit in history
git commit
git reset --soft HEAD~2 &&
git commit --edit -m"$(git log --format=%B --reverse HEAD..HEAD@{1})"
The second command opens the combination of the commit messages in commits involved for editing. The last is the
git reset 'HEAD@{1}'
Thank You.
Copyright @johngorithm
Software Developer @Ginger.io