# Git Commit Amend

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

**Field:** Software Development  
**Category:** Version Control  
**Also known as:** git commit --amend, Amend a Commit, Amend Commit

## Think of it like

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

## 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

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

## 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.

## Why it matters

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

## Common mistake

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

## Three principles

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

## Related terms

- [Commit](https://learn.benibix.com/term/development/commit)
- [Commit Message](https://learn.benibix.com/term/development/commit-message)
- [Git Reset](https://learn.benibix.com/term/development/git-reset)
- [Git Revert](https://learn.benibix.com/term/development/git-revert)
- [Commit Hash](https://learn.benibix.com/term/development/commit-hash)

## Taught in

- [Undo a Git Commit](https://learn.benibix.com/learn/development-version-control/undo-a-git-commit): Git and GitHub, 7/13

![Three rows, each starting from commits A, B and C in a line. Revert, lit up, adds a new commit D that undoes C, so history only grows and is safe to share. Reset moves the branch label back from C to B, so C drops out of the branch. Amend swaps C for a new C with a fixed message or file. A note says reset and amend rewrite history, so use them only on commits you have not pushed.](https://learn.benibix.com/diagrams/dev3-undo-changes.svg)

---

Source: https://learn.benibix.com/term/development/git-commit-amend
Author: Behnia Zarei (a developer in Vienna, Austria, who builds and teaches data, AI and business intelligence at BENIBIX)
Publisher: BENIBIX Learn (https://learn.benibix.com/)
Last updated: 2026-11-17
Licence: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Quote freely with attribution.
