Undo last commit
Keep changes in working tree, only remove the last commit:
git reset --soft HEAD~1Discard the last commit and its changes (destructive):
git reset --hard HEAD~1Amend the last commit (change message or add more changes):
git commit --amend -m "New message"# or stage more files, then:git commit --amend --no-editIf already pushed, you need to force-push after reset/amend: git push --force-with-lease (prefer over --force to avoid overwriting others’ work).