Git undo helper
What happened? Pick it below and get the exact commands to undo it, what each one does in plain words, and a warning when something can be lost. Then try the fix in a safe practice terminal right on the page.
Commits
Files and staging
Branches and merges
Already pushed
Rescue
nothing is lost rewrites history: fine before you push deletes work
Practise this in 5 minutes
Lesson 28, Undo changes, walks you through staging, restoring and undoing commits in a safe terminal, step by step, and checks your answers.
Practise it nowPart of Pro. Or start the free lessons
Keep the terminal cheat sheet handy: free to print