For latest commit: git reset --hard HEAD~1 / git reset --hard git push origin HEAD --force https://stackoverflow.com/questions/1338728/delete-commits-from-a-branch-in-git For old commits: git rebase -i Change pick to drop for commits which you want to delete. Maybe resolve conflict and continue rebase Change a new message commit git push --force
P -> Q -> R \ .--> X -> Y P -> Q -> R \ .--> Z git rebase -i Change pick to squash for some commits which want to squash. Save and quit. Change a new message commit for squashing. Save and quit. git push --force https://github.com/servo/servo/wiki/Beginner's-guide-to-rebasing-and-squashing
For the latest commit: git commit --amend I n text editor, edit the commit message, and save the commit. git push --force https://help.github.com/en/articles/changing-a-commit-message For old commits: git rebase -i ( previous commit which you want to change message) On top of text edtior, change pick to reword Change a new message commit git push --force https://stackoverflow.com/questions/1884474/change-old-commit-message-on-git