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

Why 'git commit --amend' generates different HEAD sha1 each time when no content changes

From
Ping Yin <pkufranky@gmail.com>
Date
Dec 30, 2007, 10:56 UTC
Message-ID
<46dff0320712300256g36e825a2g711d98b565e361f9@mail.gmail.com>

AFAIK, commit sha1 is only determined by commit object content (say parent commit, tree sha1 and so on). So why 'git commit --amend' changes the commit sha1 when no content changes as following shows.

$ mkdir A && cd A && echo foo >foo
$ git init && git add foo && git commit -m 'add file foo'
Created initial commit 8626800: add file foo
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo
$ git commit --amend
Created commit 3591035: add file foo
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo
$ git commit --amend
Created commit 3927d9a: add file foo
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 foo
-- 
Ping Yin
Next: Ping Yin
Message 1 of 3 in “Why 'git commit --amend' generates different HEAD sha1 each time when no content changes”
  1. Ping YinDec 30, 2007
  2. Ping YinDec 30, 2007
  3. Ping YinDec 30, 2007

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.