"I don't want this commit at all"
The same real commit, undone three different ways. Feel exactly what soft, mixed, and hard reset each really do.
A real experimental garnish idea gets committed on its own throwaway branch — reset-practice, branched off master specifically so nothing here risks the real project. "Undo this commit" sounds like one request, but git genuinely offers three different answers, depending on what should happen to the file itself.\n\nThis lesson recreates the exact same commit three times and undoes it a different way each time, so the real difference between soft, mixed, and hard is something you see directly rather than memorize from a table.
A Real, Disposable Commit
git checkout -b reset-practice
# create experiment.md
git commit -m "Try a new experimental garnish idea"
A dedicated throwaway branch — nothing here touches master.
--soft: Uncommit, Keep It Staged
git reset --soft HEAD~1
git status
The commit is genuinely gone from the log, but experiment.md is right back in the staging area — ready to be recommitted immediately, perhaps with a different message.
--mixed (the default): Uncommit and Unstage
git commit -m "Try a new experimental garnish idea" # recreate it
git reset HEAD~1
git status
Same uncommit, but the staging area is also cleared — experiment.md is back to untracked, its content still genuinely sitting on disk.
--hard: Uncommit, Unstage, and Discard
git add experiment.md && git commit -m "Try a new experimental garnish idea" # recreate it again
git reset --hard HEAD~1
ls
The commit is gone, and so is the file itself — genuinely removed from the working directory. This is the one mode where real content is actually lost, not just re-staged.
git reset --soft HEAD~1
Moves the branch pointer back one commit; the staging area and working directory are both left exactly as they were. Confirmed directly in this lab: the undone commit's changes landed right back in the staging area, ready to recommit.
git reset HEAD~1 (mixed, the default)
Moves the branch pointer back one commit AND clears the staging area; the working directory is untouched. Confirmed directly in this lab: experiment.md genuinely reverted to untracked, its content still present on disk.
git reset --hard HEAD~1
Moves the branch pointer back one commit, clears the staging area, AND overwrites the working directory to match the target commit — discarding anything the undone commit added. Confirmed directly in this lab: experiment.md was genuinely gone from disk afterward.
🌿 Create a Real Throwaway Branch and Commit
Branch off master specifically for this experiment, and make one real, disposable commit.
cd ~/recipes && git checkout -b reset-practicecd ~/recipes && printf 'Experimental Garnish\n\nTry a candied bacon crumble on top of the waffles.\n' > experiment.mdcd ~/recipes && git add experiment.mdcd ~/recipes && git commit -m 'Try a new experimental garnish idea'student@lab:~$ cd ~/recipes && git checkout -b reset-practice Switched to a new branch 'reset-practice' student@lab:~$ cd ~/recipes && printf 'Experimental Garnish\n\nTry a candied bacon crumble on top of the waffles.\n' > experiment.md student@lab:~$ cd ~/recipes && git add experiment.md student@lab:~$ cd ~/recipes && git commit -m 'Try a new experimental garnish idea' [reset-practice 099568e] Try a new experimental garnish idea 1 file changed, 3 insertions(+) create mode 100644 experiment.md
🟡 Soft Reset: Uncommit, Keep It Staged
Undo the commit with --soft and see the change land right back in the staging area.
cd ~/recipes && git reset --soft HEAD~1cd ~/recipes && git statusstudent@lab:~$ cd ~/recipes && git reset --soft HEAD~1 student@lab:~$ cd ~/recipes && git status On branch reset-practice Changes to be committed: (use "git restore --staged <file>..." to unstage) new file: experiment.md Untracked files: (use "git add <file>..." to include in what will be committed) notes.txt
🟠 Mixed Reset: Uncommit and Unstage
Recommit, then undo with plain git reset (mixed, the default) and watch the staging area clear too.
cd ~/recipes && git commit -m 'Try a new experimental garnish idea'cd ~/recipes && git reset HEAD~1cd ~/recipes && git statusstudent@lab:~$ cd ~/recipes && git commit -m 'Try a new experimental garnish idea' [reset-practice 4420b3a] Try a new experimental garnish idea 1 file changed, 3 insertions(+) create mode 100644 experiment.md student@lab:~$ cd ~/recipes && git reset HEAD~1 student@lab:~$ cd ~/recipes && git status On branch reset-practice Untracked files: (use "git add <file>..." to include in what will be committed) experiment.md notes.txt nothing added to commit but untracked files present (use "git add" to track)
🔴 Hard Reset: Discard the File Entirely
Recommit one more time, then undo with --hard and see experiment.md genuinely disappear from disk.
cd ~/recipes && git add experiment.mdcd ~/recipes && git commit -m 'Try a new experimental garnish idea'cd ~/recipes && git reset --hard HEAD~1cd ~/recipes && lsstudent@lab:~$ cd ~/recipes && git add experiment.md student@lab:~$ cd ~/recipes && git commit -m 'Try a new experimental garnish idea' [reset-practice b8631e6] Try a new experimental garnish idea 1 file changed, 3 insertions(+) create mode 100644 experiment.md student@lab:~$ cd ~/recipes && git reset --hard HEAD~1 HEAD is now at 81d9759 Add taco and salsa recipes student@lab:~$ cd ~/recipes && ls BRANCHING.md cookies.md eggs.md notes.txt pasta.md salad.md salsa.md soup.md tacos.md waffles.md
Lab 1.4.4 complete — and Block 1.4 complete. The same commit, undone three genuinely different ways:\n\n\n --soft : commit gone, file STAGED : ✅ confirmed\n --mixed : commit gone, file UNSTAGED : ✅ confirmed\n --hard : commit gone, file DISCARDED : ✅ confirmed\n
Enable JavaScript to run the live terminal and track your progress.