🎯 Module 05: Undoing Things in Git | Reset, Revert, Restore, Stash & Relog
Accidentally deleted files? Lost commits after a reset? Need to undo changes safely in Git?
In this hands-on Git tutorial, you'll learn the most important Git recovery commands that every developer should know. We'll cover how to discard changes, unstage files, undo commits, save work temporarily, and even recover commits that seem lost forever using Git Reflog.
Whether you're a beginner or an experienced developer, these Git recovery techniques will save you hours of frustration and help you work confidently with Git.
📚 Topics Covered
✅ Git Restore – Discard changes safely
✅ Git Reset – Soft, Mixed & Hard Reset
✅ Git Revert – Undo commits without rewriting history
✅ Git Stash – Save work for later
✅ Git Reflog – Recover lost commits
✅ Recovering deleted commits step-by-step
✅ Real-world recovery scenarios
✅ Best practices for undoing changes safely
💻 Commands Used In This Video
Git Restore
git restore README.md
git restore --staged config.js
git restore .
git restore --source=HEAD~2 file.js
Git Reset
git reset --soft HEAD~1
git reset --mixed HEAD~1
git reset --hard HEAD~1
Git Revert
git log --oneline
git revert a3f1c2b
git revert HEAD~3..HEAD
git revert --no-commit a3f1c2b
Git Stash
git stash
git stash push -m "WIP: login form"
git stash list
git stash pop
git stash apply
git stash drop
git stash clear
Git Reflog & Recovery
git reflog
git reset --hard HEAD@{2}
git branch recovered HEAD@{2}
Recovery Workflow
git reflog
git branch recovered hash
Additional Useful Commands
git commit --amend -m "new msg"
git switch other-branch
git switch back-to-original
⏱️ What You'll Learn
• Difference between Restore, Reset and Revert
• When to use Soft, Mixed and Hard Reset
• Safe ways to undo commits in shared repositories
• How Git Stash helps manage unfinished work
• Recover deleted commits using Reflog
• Best practices to avoid losing code
🔥 Git Zero to Pro Playlist
✔ Git Basics
✔ Git Internals
✔ Working with Remotes
✔ Branching & Merging
✔ Undoing Things (This Video)
✔ Collaboration Workflows
✔ Advanced Git Techniques
👍 If You Found This Helpful
✅ Like the video
✅ Share with fellow developers
✅ Subscribe to Shiva Tech Hub
✅ Turn on notifications for upcoming Git modules
💬 Have you ever recovered a lost commit using Git Reflog? Let me know in the comments below!