git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 0/2] commit: preserve commit hash on a no-op amend

From
Harald Nordgren via GitGitGadget <gitgitgadget@gmail.com>
Date
Jun 13, 2026, 09:16 UTC
Message-ID
<pull.2334.git.git.1781342189.gitgitgadget@gmail.com>

git commit --amend --no-edit rewrote the commit and moved the branch tip even when nothing changed, because the committer date was reset to "now". Reuse the existing committer date so a no-op amend keeps the commit hash and leaves the branch untouched.

A real change (tree, message, author, committer, or signing) still rewrites as before.

Harald Nordgren (2):
  commit: extract commit_index_files_or_die() helper
  commit: keep the commit on a no-op amend
 Documentation/git-commit.adoc         |   6 ++
 builtin/commit.c                      |  69 ++++++++++++++-
 t/t7501-commit-basic-functionality.sh | 119 ++++++++++++++++++++++++++
 3 files changed, 190 insertions(+), 4 deletions(-)
base-commit: ea97ad8d017de0c9037451a78008a0fd60abea0c
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-2334%2FHaraldNordgren%2Famend-noop-keeps-commit-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-2334/HaraldNordgren/amend-noop-keeps-commit-v1
Pull-Request: https://github.com/git/git/pull/2334
-- 
gitgitgadget
Next: Harald Nordgren via GitGitGadget
Message 1 of 7 in “commit: preserve commit hash on a no-op amend”
  1. 0/2 commit: preserve commit hash on a no-op amendHarald Nordgren via GitGitGadget, Jun 13, 2026
  2. 1/2 commit: extract commit_index_files_or_die() helperHarald Nordgren via GitGitGadget, Jun 13, 2026
  3. 2/2 commit: keep the commit on a no-op amendHarald Nordgren via GitGitGadget, Jun 13, 2026
  4. Johannes SixtJun 13, 2026
  5. Ben KnobleJun 13, 2026
  6. Junio C HamanoJun 13, 2026
  7. Harald NordgrenJun 13, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.