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

Re: Commiting unchanged tree

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Sep 18, 2010, 09:30 UTC
Message-ID
<AANLkTi=ODMjevBTLSK8W1AcdiiSiX=yfQfr_kK7Bh-cn@mail.gmail.com>
In-Reply-To
<loom.20100918T095640-130@post.gmane.org>
On Sat, Sep 18, 2010 at 08:15, Maaartin <grajcar1@seznam.cz> wrote:
Show 18 quoted lines
> I thought that calling
>
> git commit --amend -m "A message"
>
> twice in a row should lead to an error saying "nothing to commit (working
> directory clean)", but it doesn't. Or at least, the result of the second commit
> should be the same as the result of the first one, but I keep getting a
> different hash each time
>
> # git commit --amend -m "A message"
> [master b8cf1c2] A message
> # git commit --amend -m "A message"
> [master 6c8ea30] A message
> # git commit --amend -m "A message"
> [master be318b3] A message
>
> I wonder if everything is fine with my repo since I was doing some funny
> rebasing and filtering and I'm quite new to git.

This is expected behavior. You're telling Git to amend the latest commit with a new commit message (which happens to be equivalent to the old one), and your sha1 keeps changing because the `commiter` time entry in the commit changes every time you commit (well, with a granularity of 1 second):

    v foo (master) $ git commit --amend -m"blah"; GIT_PAGER=cat git
show --pretty=raw
    [master 9cc96c7] blah
     0 files changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 blah
    commit 9cc96c71ae30f94afaf891be58671a0adf89cedb
    tree c4bf67b477e5e7470266b4227a664f7b175c9d4a
    author Ævar Arnfjörð Bjarmason <avarab@gmail.com> 1284802065 +0000
    committer Ævar Arnfjörð Bjarmason <avarab@gmail.com> 1284802096 +0000
        blah
    diff --git a/blah b/blah
    new file mode 100644
    index 0000000..e69de29
    v foo (master) $ git commit --amend -m"blah"; GIT_PAGER=cat git
show --pretty=raw
    [master bc71b18] blah
     0 files changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 blah
    commit bc71b18ae254b33e895ee840825bf357baa40e00
    tree c4bf67b477e5e7470266b4227a664f7b175c9d4a
    author Ævar Arnfjörð Bjarmason <avarab@gmail.com> 1284802065 +0000
    committer Ævar Arnfjörð Bjarmason <avarab@gmail.com> 1284802097 +0000
        blah
    diff --git a/blah b/blah
    new file mode 100644
    index 0000000..e69de29
    v foo (master) $
Note the difference between 1284802096 and 1284802097 there.
Previous: Maaartin
Message 2 of 2 in “Commiting unchanged tree”
  1. MaaartinSep 18, 2010
  2. Ævar Arnfjörð BjarmasonSep 18, 2010

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.