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

Re: just curious: what influences a commit hash?

From
Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Date
Mar 5, 2009, 09:02 UTC
Message-ID
<20090305090221.GA28687@pengutronix.de>
In-Reply-To
<1236237939.2421.38.camel@virgil>
Hi,
On Thu, Mar 05, 2009 at 02:25:39AM -0500, Matt Enright wrote:
Show 5 quoted lines
> On Thu, 2009-03-05 at 07:36 +0100, stoecher@gmx.at wrote:
> > Hi,
> > 
> > being new to git I did some experiments with commits looking at the hashes. What I observed:
> > * The same commit (same file, same committer, same message) into different empty repositories (git init) gives different hashes. So I assume that also the time of the commit influences the hash. Is this intended? For what reason?
Yes, commit time and commit date influence the hash.

But the hashes for the corresponding trees should be the same. Check the output of git rev-parse $commit^{tree}.

If you want to reproduce the exact same commit, you need to set the env variables GIT_AUTHOR_DATE and GIT_COMMITTER_DATE. (Not sure, but GIT_AUTHOR_DATE might be handled by git am.)

Best regards Uwe

-- 
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |
Previous: Matt EnrightNext: Matthieu Moy
Message 3 of 4 in “just curious: what influences a commit hash?”
  1. stoecher@gmx.atMar 5, 2009
  2. Matt EnrightMar 5, 2009
  3. Uwe Kleine-KönigMar 5, 2009
  4. Matthieu MoyMar 5, 2009

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.