"I committed with a typo in the message"
A real typo in the message, and a real forgotten file. Fix both at once, before anyone else ever sees either.
Two real mistakes at once, which happens more often than either alone: the commit message has a genuine typo ("Addd" instead of "Add"), and salsa.md — meant to be part of the same commit as tacos.md — never got staged before you hit enter.\n\nAs long as this commit has not been pushed or shared, git commit --amend genuinely fixes both problems at once: stage the forgotten file, then amend with the corrected message. One clean commit results — no trace of the mistake remains in the history anyone else will ever see.
The Real Mistake
git add tacos.md
git commit -m "Addd taco recipe"
A real typo, and salsa.md — meant to accompany it — is still sitting there untracked.
Staging What Was Forgotten
git add salsa.md
Now it is ready to be folded into the same commit, rather than becoming its own separate, oddly-scoped one.
Fixing Both at Once
git commit --amend -m "Add taco and salsa recipes"
This genuinely replaces the previous commit entirely: the newly-staged salsa.md is included, and the message is corrected — one real, clean commit, with a completely new hash.
The One Real Rule
Amend is for commits that exist only on your machine. The moment a commit has been pushed or shared, amending it creates a genuine hash mismatch with whatever anyone else already has — that scenario is covered later, with the safe alternative (git revert).
git commit --amend -m <message>
Replaces the most recent commit with a new one: whatever is currently staged (including anything staged since the original commit) plus the new message. Confirmed directly in this lab producing a genuinely new commit hash, since the content changed.
📝 Commit With a Typo, Forget a File
Write two real, related recipes, but stage and commit only one of them, with a genuine typo in the message.
cd ~/recipes && printf 'Beef Tacos\n\nSeason beef, warm tortillas, assemble with toppings.\n' > tacos.mdcd ~/recipes && printf 'Fresh Salsa\n\nDice tomatoes, onion, cilantro; mix with lime juice and salt.\n' > salsa.mdcd ~/recipes && git add tacos.mdcd ~/recipes && git commit -m 'Addd taco recipe'student@lab:~$ cd ~/recipes && printf 'Beef Tacos\n\nSeason beef, warm tortillas, assemble with toppings.\n' > tacos.md student@lab:~$ cd ~/recipes && printf 'Fresh Salsa\n\nDice tomatoes, onion, cilantro; mix with lime juice and salt.\n' > salsa.md student@lab:~$ cd ~/recipes && git add tacos.md student@lab:~$ cd ~/recipes && git commit -m 'Addd taco recipe' [master b1aa0cb] Addd taco recipe 1 file changed, 3 insertions(+) create mode 100644 tacos.md
🔍 Confirm What Was Left Behind
Check git status and see salsa.md genuinely sitting there, untracked, never part of the commit.
cd ~/recipes && git statusstudent@lab:~$ cd ~/recipes && git status On branch master Untracked files: (use "git add <file>..." to include in what will be committed) notes.txt salsa.md nothing added to commit but untracked files present (use "git add" to track)
✏️ Amend the Commit, Fixing Both Problems
Stage the forgotten file, then amend with a corrected message — fixing the typo and including salsa.md together.
cd ~/recipes && git add salsa.mdcd ~/recipes && git commit --amend -m 'Add taco and salsa recipes'student@lab:~$ cd ~/recipes && git add salsa.md student@lab:~$ cd ~/recipes && git commit --amend -m 'Add taco and salsa recipes' [master 2bb0692] Add taco and salsa recipes Date: Mon Aug 24 19:34:11 2026 +0000 2 files changed, 6 insertions(+) create mode 100644 salsa.md create mode 100644 tacos.md
🔎 Confirm the New, Real Hash
Verify with git show and git log that the amended commit is genuinely a brand new commit, not an edit of the old one.
cd ~/recipes && git show --name-onlycd ~/recipes && git log --oneline -3student@lab:~$ cd ~/recipes && git show --name-only commit 2bb0692239fc78f4cf4e6baa50ba929a6bfb6f5c (HEAD -> master) Author: Ada Lovelace <ada@example.com> Date: Mon Aug 24 19:34:11 2026 +0000 Add taco and salsa recipes salsa.md tacos.md student@lab:~$ cd ~/recipes && git log --oneline -3 2bb0692 (HEAD -> master) Add taco and salsa recipes 6293056 Add scrambled eggs recipe 0f17cc4 Document branch naming convention
Lab 1.4.2 complete. A real typo and a real forgotten file, fixed together in one clean step:\n\n\n Typo'd commit made : ✅ genuine mistake, committed\n Forgotten file staged : ✅ salsa.md ready to join\n Amended in one step : ✅ message fixed, file included\n New hash confirmed : ✅ old commit genuinely gone\n
Enable JavaScript to run the live terminal and track your progress.