Find the SHA of the commit you want squash to

Commit: SHA1
Commit: SHA2
Commit: SHA3
git rebase -i SHA3
git rebase -i HEAD^^^

Cntl-v enter visual mode
Select text
c – to delete
Type what you want to appear
Press ‘Esc’ x2
Add a ‘p’ to bottom commit

Edit your file appropriately. Then save.

If you make a mistake

git rebase --abort

If you want to change a commit message

git commit --amend

Two squash two commits together:

git rebase --interactive HEAD~2

Dont reorder. Just take as is and change commit message when done.

Then force push your changes back to branch.

git push --force -n