Skip to content
BENIBIX Learn

Git Commit Amend

Development🔀 Version ControlUndo Commands

Also known as git commit --amend, Amend a Commit, Amend Commit

Fixing your last commit before you share it. You can change its message or its files.

Think of it like

Think of it like fixing a letter before you post it. You change a word and seal it again.

Example

Lucy commits and then sees a typo in her message. She runs git commit --amend and fixes it.

Why it matters

Small slips get fixed without a second commit that just says oops.

Definition

Amend replaces your last commit with a fixed one. You can change its message, add a file you forgot, or both. Git makes a new commit with a new hash in its place. The old one drops out of the branch. Because history changes, amend only commits you have not pushed.

Example code

console
$ git commit --amend -m "Fix the price on the order page"
[main 7b8c9d0] Fix the price on the order page
 Date: Mon Nov 16 10:12:03 2026 +0100
 1 file changed, 2 insertions(+), 1 deletion(-)
The last commit is swapped for one with the new message.
Amend swaps commit C for a fixed copy of it.

Common mistake

Amending a commit already pushed. Others now have a commit that no longer exists on yours.

Key takeaways

  1. 1
    Last commit only. It fixes the newest commit.
  2. 2
    New hash. The fixed commit is a new one.
  3. 3
    Before you push. Do not amend shared commits.

Learn it properly