News for hackers. Stuff that matters.
Re:How to publish Git repos that cannot be republished to Gi... by jaytaylor on Monday November 02, 2020 @08:29PM (#24975430)
edit- thanks commenters for the correction!

Git commit hashes are indeed deterministic, though it depends on the inputs.

From StackOverflow [0]:

Git uses the following information to generate the sha-1:

* The source tree of the commit (which unravels to all the subtrees and blobs)

* The parent commit sha1

* The author info (with timestamp)

* The committer info (right, those are different!, also with timestamp)

* The commit message

[0] https://stackoverflow.com/a/34764586/293064

Re:How to publish Git repos that cannot be republished to Gi... by klodolph on Monday November 02, 2020 @08:46PM (#24975531)
It's deterministic, you've just changed the inputs. The "committer date" is usually excluded from logs so you don't see it, but it's the only missing input. Here is a demo:

    $ git rev-parse HEAD 
    78d66a4f169fec9cb9b3252f7a22bb020e967cd2

    $ git log HEAD      
    commit 78d66a4f169fec9cb9b3252f7a22bb020e967cd2 (HEAD -> master)
    Author: XXXX
    Date:   Mon Nov 2 20:44:04 2020 -0500

        temp2

    $ git reset --soft HEAD\^

    $ GIT_COMMITTER_DATE='Mon Nov 2 20:44:04 2020 -0500' GIT_AUTHOR_DATE='Mon Nov 2 20:44:04 2020 -0500' git commit -m temp2
    [master 78d66a4] temp2
     1 file changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 b

    $ git rev-parse HEAD
    78d66a4f169fec9cb9b3252f7a22bb020e967cd2
Re:How to publish Git repos that cannot be republished to Gi... by wldlyinaccurate on Monday November 02, 2020 @08:45PM (#24975529)
Git commit hashes _are_ deterministic. Run `git cat-file -p <hash>` on your two hashes. The timestamp in the committer field will be different. That is why the hash changed.