AcademyUndo Your Last Commit in Git 🔙
TutorialBeginner

Undo Your Last Commit in Git 🔙

Made a mistake? Learn how to step back safely using Git Reset.

November 25, 2025
Cyrus 365
1 min read
GitVersion ControlWorkflow

We've all been there: you typed git commit, hit enter, and immediately realized you forgot a file or made a typo. Don't panic! You can easily undo that commit.

Option 1: The Soft Reset (Safe)

Use this if you want to undo the commit action but keep your file changes. Your work will move back to the 'Staged' area.

bash
git reset --soft HEAD~1

Option 2: The Hard Reset (Destructive)

⚠️ Warning: Use this only if you want to completely destroy the commit and delete all changes in it. There is no going back.

bash
git reset --hard HEAD~1

Summary

1

Use --soft to fix a mistake and commit again.

2

Use --hard to trash the work entirely.

3

HEAD~1 simply means 'go back 1 commit'.