IT lexicon › Programming › Amend (git commit --amend)

Amend (git commit --amend)

Programming På svenska → Updated: 2026-11-13

Modifying a commit by adding new changes or rewriting the message — without creating a separate fixup commit.

`git commit --amend` takes the last commit and adds staged changes to it. The commit hash changes (since content and timestamp are part of the hash), so if you already pushed you need force-push to rewrite the server. For local work it's routine and safe — for shared or upstream branches it's scary.

The alternative is a new fixup commit followed by `git rebase -i` to squash them, but amend is faster for small corrections before push. Many developers use amend daily for minor fixes.

← Back to the lexicon