All fixes

Help, I want to undo my last commit but keep the changes

Take back the last commit and keep every change in it, ready to fix up and commit again.

The fix

  1. git reset --soft HEAD~1

    The commit is gone from the branch, and all its changes are staged again. Edit, then commit when ready.

What happens to your historygit reset --soft HEAD~1
BeforeABCHEADmain
AfterABCHEADmain

Why this works

reset --soft only moves the branch back one commit. Your files and the staging area stay exactly as they were, so the changes from that commit are simply staged again. Once a commit is pushed, moving the branch back would pull the rug from under everyone who has it. revert instead adds a new commit that undoes it, and cherry-pick --no-commit brings the changes back into your working copy to keep working on.