Go home
pinned

Undo the Last Git Commit (Keep Changes)

Reset the last commit while keeping your staged changes intact.

git cli

The Command

git reset --soft HEAD~1

This keeps all your changes staged. Use --mixed instead if you want them unstaged.

When to Use It

  • You committed too early
  • You want to amend the commit message or add more files
  • You realized the commit belongs on a different branch

Nuclear Option

If you want to throw away the changes entirely:

git reset --hard HEAD~1

Warning: --hard discards everything. Only use it if you’re sure.