Cyrus 365Academy
cyrus365.com

© 2019-2026 Cyrus 365. All rights reserved.

AcademySolutionsContact
Cyrus 365Academy
cyrus365.com
Back to Academy
TutorialBeginner

Undo Your Last Commit in Git 🔙

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

25 Nov 2025Cyrus 3651 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. 1Use --soft to fix a mistake and commit again.
  2. 2Use --hard to trash the work entirely.
  3. 3HEAD~1 simply means 'go back 1 commit'.

Related articles

Tutorial•2 Jul 2026•Intermediate

Getting Started with Claude Code: Anthropic's Agentic CLI

Learn how to install, configure, and use Claude Code—an autonomous terminal assistant that can edit files, run tests, and manage git workflows directly in your project.

By Cyrus 365
Tutorial•26 Nov 2025•Beginner

Never Forget a Password Again: Intro to Bitwarden 🛡️

Secure your digital life with the best free, open-source password manager. Learn to store, generate, and sync credentials securely.

By Cyrus 365
Tutorial•26 Nov 2025•Beginner

Master Remote Access with Bitvise SSH Client 🛡️

Unlock professional-grade server management on Windows. Learn to connect, transfer files, and tunnel securely with Bitvise.

By Cyrus 365

© 2019-2026 Cyrus 365. All rights reserved.

AcademySolutionsContact