Desk Clarity

A field guide to everyday digital problems.

Developer tools / Practical guide

Git Amend No-Edit Still Changes History: Understand a Rejected Push

Keep a message unchanged while recognizing that amend creates a replacement commit.

By ON Lab3 min readSources checked November 10, 2026 (KST)

--no-edit keeps the selected commit message; it does not preserve the old commit object. Amending staged changes replaces the branch tip with a new commit, which can make a normal push diverge from an already-published tip.

Reproduce the boundary in a disposable fixture

Keep a message unchanged while recognizing that amend creates a replacement commit.

Use a new empty temporary directory for this fixture. The example creates only local test data. Commands marked with example.invalid do not identify a real service.

git init -q demo
cd demo
git config user.name Fixture
git config user.email fixture@example.invalid
printf 'one
' > note.txt
git add note.txt
git commit -qm original
old=$(git rev-parse HEAD)
printf 'two
' >> note.txt
git add note.txt
git commit --amend --no-edit -q
new=$(git rev-parse HEAD)
test "$old" != "$new"
git show -s --format='%h %s' "$old" "$new"
git diff "$old" "$new" -- note.txt

Observed result

234820d original
09fbd4f original
diff --git a/note.txt b/note.txt
index 5626abf..814f4a4 100644
--- a/note.txt
+++ b/note.txt
@@ -1 +1,2 @@
 one
+two

What the result means

The subjects match, but the object IDs differ and the new tree contains another line. This is a replacement commit, not a child commit added after the old one. A remote that still points at the old object does not automatically see the new object as its descendant. A push rejection in that situation is consistent with history replacement even when the author works alone.

Choose the correction for your workflow

Before amending, inspect git status and git diff --cached so unrelated staged changes are not folded in. Use amend for a local tip when replacement is intended. If the original commit has already been shared and replacement is unnecessary, a normal follow-up commit keeps history easier to integrate. If shared history really must be rewritten, coordinate the change and review the remote state under the repository policy. Do not use a force push as a reflex to an error message.

Limits and the next check

This fixture changes content deliberately and makes no network request. An amend with no content or metadata difference is not a useful way to prove an ID must always change. Author, committer metadata, parents, message and tree all contribute to commit identity. --no-edit controls editor/message selection, not staging, push permissions or conflict recovery. The guide does not prescribe rewriting protected or shared branches.

Related: Compare the related workflow boundary.

This isolated example was executed on macOS on November 10, 2026 (KST). Available tools: node v26.5.0, git git version 2.39.3 (Apple Git-145), npm 11.17.0, jq jq-1.7.1-apple. Shell fixtures use Bash and repository-path identity uses Python 3. This checks the illustrated contract, not your project, host service or every tool version.

Sources & further reading