A commit titled “Add introdution” sat one commit below the tip of a test repository built for this post, typo and all, along with a file that needed one more line. The lazy fix is a new commit called “fix typo” on top. The clean fix rewrites the original so the history reads as if the mistake never happened, and Git ships three tools for that: --amend for the last commit, --fixup for an older one, and rebase --autosquash to fold the fixes in. Every command below was run in Git 2.43.0, and the output shown is what it printed.
Amending the last commit
What –amend actually does
The git-commit documentation describes --amend in one line: “Replace the tip of the current branch by creating a new commit.” The word that matters is new. Git does not edit the old commit. It builds a replacement with the same parents and author and points the branch at it.
That shows up in the hash. In the test repository, the last commit was 9adcd4b Add chapter one. After this:
git commit --amend -m "Add chapter one draft"the branch tip became 0efd46a Add chapter one draft. Different message, different hash, different commit.
Adding a forgotten file
The most common use isn’t the message at all. It is the file left out of the commit:
git add notes.txt
git commit --amend --no-edit--no-edit keeps the existing message. The commit’s file list went from one file to two, c.txt and notes.txt, and the hash changed again, to 4693e52.
Two dates, and only one moves
Every Git commit carries two timestamps: when the change was authored and when the commit object was made. The docs say an amended commit keeps “the same parents and author as the current one,” and adds that “the --reset-author option can countermand this.” A separate small test checked what that means in practice. A commit made with both dates set to January 10 was amended with the committer clock set to January 12:
author 2026-01-10 10:00:00 -0500
committer 2026-01-12 09:30:00 -0500
The author date stayed put; the committer date moved. Amending again with --reset-author replaced the author date with the current time on the machine. That matters for anyone who reads git log, which shows the author date by default: a plain amend leaves the original timestamp in the log even though the commit object is brand new. Tools that sort by committer date will see it differently. Neither is wrong. They answer different questions, and knowing which one a dashboard or changelog reads avoids a confusing afternoon.
The old commit is still there, for a while
Amending feels destructive, but the reflog kept a trail:
4693e52 HEAD@{0}: commit (amend): Add chapter one draft
0efd46a HEAD@{1}: commit (amend): Add chapter one draft
9adcd4b HEAD@{2}: commit: Add chapter one
Every version is listed. git reset --hard HEAD@{2} would bring back the original. The reflog is local and eventually expires, so it is a safety net for minutes and days, not an archive.

Fixing a commit further back
The problem –amend can’t solve
--amend only touches the tip. The typo in “Add introdution” was one commit below the top, with “Add chapter one” sitting on it. Amending would change the wrong commit.
Making a fixup commit
The documentation says --fixup=<commit> creates a commit that “fixes up” the target “when applied with git rebase --autosquash.” Plain --fixup “changes the content of
echo "intro, fixed" > b.txt
git add b.txt
git commit --fixup=HEAD~1Git wrote the title itself: fixup! Add introdution. Per the docs, that title is “fixup!” followed by the target’s title, and it is “recognized specially by git rebase --autosquash.” The fixup commit doesn’t change anything yet. It is a labeled note saying where its changes belong.
Fixing the message too
The typo is in the message, which plain fixup won’t touch. Git 2.32 added two variants; its release notes say --fixup “learned “–fixup=(amend|reword):reword: as one that “replaces the log message of
git commit --fixup=reword:HEAD~2That opens an editor holding amend! Add introdution as the title and the old message below it. Changing the body to “Add introduction” and saving produced commit ad9a19d amend! Add introdution.
One thing the test turned up: Git 2.43 refused -m here, with fatal: options '-m' and '--fixup:reword' cannot be used together. The reword message has to go through the editor.
Folding fixes in with –autosquash
What the rebase does
At this point the log read, newest first:
ad9a19d amend! Add introdution
6043ccd fixup! Add introdution
ec3cd9a Add chapter one
af0f724 Add introdution
373965d Add title page
3e1a834 Start
The git-rebase documentation explains what --autosquash does with that: when a commit message begins with “squash!”, “fixup!” or “amend!” and a matching commit exists, it rearranges the interactive to-do list so “the commit marked for squashing comes right after the commit to be modified,” changing its action to squash, fixup or fixup -C.
The to-do list, as Git arranged it
Running git rebase -i --autosquash HEAD~5 and capturing the to-do list before it executed gave:
pick 373965d Add title page
pick af0f724 Add introdution
fixup 6043ccd fixup! Add introdution
fixup -C ad9a19d amend! Add introdution # empty
pick ec3cd9a Add chapter one
Both fix commits moved up under their target. No hand-editing was needed. The # empty note is accurate: the reword commit carried a message and no file changes.
The result
66df3bd Add chapter one
25fa19f Add introduction
373965d Add title page
3e1a834 Start
The typo is gone, b.txt in that commit now reads “intro, fixed”, and the two helper commits have vanished into it. “Add chapter one” kept its content but got a new hash, because its parent changed. Every commit after the edited one gets rewritten.

Version differences that bite
Non-interactive autosquash
In Git 2.43, running git rebase --autosquash HEAD~3 without -i printed “Successfully rebased” and changed nothing. Both fixup commits were still sitting in the log. That is not a bug in the test. The Git 2.44 release notes say “git rebase –autosquash” “is now enabled for non-interactive rebase,” with the caveat that it remains incompatible with the apply backend.
So on 2.44 and later, --autosquash alone does the job. On 2.43 and earlier, it needs -i, and a script can pass GIT_SEQUENCE_EDITOR=true to accept the to-do list without opening an editor. Checking git --version before trusting a blog post’s command, this one included, saves confusion.
Making it the default
The rebase docs describe a config setting, rebase.autoSquash: “If set to true enable --autosquash option by default.” One line sets it:
git config --global rebase.autoSquash trueWith that on, every interactive rebase moves fixup commits into place automatically.
Rewriting history that’s already pushed
Why this needs care
Amend and autosquash both produce new commits with new hashes. If the old ones were already pushed, the remote branch and the local one now disagree, and a normal push is rejected. The tempting answer is --force. The git-push documentation is direct about that flag: “It can cause the remote repository to lose commits; use it with care.”
Force with a lease
The safer option is --force-with-lease. The same page describes the risk it guards against: if someone else built on the original history in the meantime, the remote branch may have advanced, and “blindly pushing with --force will lose their work.” With a lease, the remote is updated only if it still matches what the local repository last saw; otherwise the push fails and nothing is overwritten.
A working rule
Rewrite freely on a branch nobody else has pulled, such as a personal feature branch before review. Once others are building on it, coordinate first or add a normal new commit instead. Clean history is nice. Teammates’ lost work is not.

A routine that keeps history readable
Commit freely, clean before review
The pattern that falls out of these tools is simple. Work in small commits. When a mistake shows up in an earlier one, commit the fix with git commit --fixup=<hash> instead of “fix typo.” Fix a bad message with --fixup=reword:<hash>. Before opening a pull request, run one rebase with autosquash and every fix lands where it belongs.
Finding the hash quickly
The <commit> part doesn’t need a full hash. HEAD~1 worked in the tests, and so does a short hash from git log --oneline. The rebase docs also note that a fixup matches its target “if the commit subject matches, or if the … refers to the commit’s hash,” and partial subject matches work as a fallback.
Squash, briefly
There is a third sibling, --squash=<commit>. The commit docs say it builds a message titled with a “squash! ” prefix. During autosquash, it combines contents like fixup but keeps both messages and opens an editor to merge them, which suits a fix whose explanation is worth keeping.
The test repository ended with four commits that read like a plan, rather than six that read like a diary. Nobody reviewing it would know there was ever a typo, and that is entirely the point.
Sources
- Git documentation, git-commit: https://git-scm.com/docs/git-commit
- Git documentation, git-rebase: https://git-scm.com/docs/git-rebase
- Git documentation, git-push: https://git-scm.com/docs/git-push
- Git 2.32.0 release notes: https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/2.32.0.adoc
- Git 2.44.0 release notes: https://raw.githubusercontent.com/git/git/master/Documentation/RelNotes/2.44.0.adoc
