reset --hard on the wrong commit, and the work is "gone". It isn't. Git keeps it in reflog. This module turns the scariest commands into everyday tools: you clean up "wip" and "fix typo" before review, undo a bad release without breaking the team, and bring "lost" commits back.
Course
Git Basics Course · Module 6 of 7 · Stage 2 "In a team"
Learn
rebase and interactive rebase, reset vs revert, stash, cherry-pick, reflog, rules for shared branches
How
4 lessons on my-plugin with three practice branches: feature/coupons, feature/debug, release/1.2
Pick the right undo
flowchart TD
Q{"Has the commit<br/>been pushed and shared?"}
Q -- "No, only on my machine" --> L["Rewrite it<br/>reset · rebase -i · --amend"]
Q -- "Yes, others have it" --> S["Add a new commit<br/>git revert"]
L --> X{"Went wrong?"}
X -- "yes" --> RF(["git reflog → back in seconds"])
classDef q fill:#fff7ed,stroke:#EE5133,color:#7c2d12
classDef safe fill:#ecfdf5,stroke:#10b981,color:#065f46
classDef rescue fill:#EE5133,stroke:#9a2a14,color:#ffffff
class Q,X q
class L,S safe
class RF rescue
Six tools, one table
Tool
Use it when
Never
git rebase -i
squash "wip" commits before a PR
on a branch others pulled
git reset
undo local commits
on shared main
git revert
roll back a bad release in main
— it's always safe
git stash
an emergency hits mid-feature
as long-term storage
git cherry-pick
one fix needed on release/1.2
instead of a proper merge
git reflog
a commit "disappeared"
— it's your safety net
You'll be able to answer
What's the difference between merge and rebase?
What's the difference between reset and revert?
How do you recover a commit after git reset --hard?
Which operations must not be done on shared branches?