Module lessons (1/4)
Fixing your latest commit with git commit --amend
Update forgotten files or commit typos into the latest local commit safely.
What you'll learn in this lesson
- Fold forgotten staged edits silently into the latest local commit without changing its message via
git commit --amend --no-edit. - Rewrite typos or missing changes cleanly inside your most recent snapshot with
git commit --amend -m "...". - Explain why amending replaces the old commit with a brand-new SHA hash while leaving the pre-amend snapshot reachable in
git reflog.
Overview
Right after creating a commit, almost every engineer notices a missing configuration file, a forgotten import, or a typo in the commit message. Creating a noisy "oops forgot config" second commit clutters pull request diffs when your branch is still private and unpushed.
git commit --amend does not edit bits inside the old commit in place—every Git commit hash (SHA) depends cryptographically on its tree, parent, author, and timestamp. Instead, Git builds a brand-new replacement commit sharing the exact same parent (HEAD~1) and moves the current branch pointer over to it:
Sections covered in this lesson
- 1Rewriting Just Your Latest Commit
- 2Watch SHA Replacement & Reflog X-Ray Live
Unlock "Fixing your latest commit with git commit --amend" and the full Git & Modern Collaboration curriculum
Update forgotten files or commit typos into the latest local commit safely.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Git & Modern Collaboration plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.