trick
Undo the last commit without losing work
Take a commit back and keep its changes.
This note is completely AI-generated. Check it before you rely on it.
Keep the changes staged:
git reset --soft HEAD~1
Keep the changes in your files, but unstaged:
git reset HEAD~1
If you already pushed the commit to a shared branch, add a new commit that reverses it instead of rewriting history:
git revert HEAD