[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