If I create a file foo
with touch foo
and then run shasum foo
it will print out
da39a3ee5e6b4b0d3255bfef95601890afd80709
The only things which are SHA-1'd to give the commit object its reference are what is shown by git show
.
commit e6e53f5256c47b039ed19e95a073484dbb97cbf7
tree 543b9bebdc6bd5c4b22136034a95dd097a57d3dd
author Alex Balhatchet 1406774132 -0700
committer Alex Balhatchet 1406774132 -0700
foo
That is:
The reason the examples with --date
from other answers haven't worked is because you need to override both the committer timestamp and the author timestamp.
For example the following is completely repeatable:
alex@yuzu:~$ ( mkdir foo ; cd foo ; git init ; export GIT_AUTHOR_DATE='Wed Jul 30 19:35:32 2014 -0700'; export GIT_COMMITTER_DATE=$GIT_AUTHOR_DATE; touch README; git add README; git commit README --message 'foo' --author 'Foo Bar '; git show HEAD --format=raw ; cd .. ; rm -rf foo ) 2>&1 | grep '^commit '
commit 7438e0a18888854650e6a53a9a5d823d6382de45
If you run it on your machine you should get exactly the same output.
Update
If you get different output it should at least be repeatable. For example I get different output for different versions of git; 1.7.10.4 reports a new empty README file as 0 files changed
whereas 1.9.1 reports it as 1 file changed, 0 insertions(+), 0 deletions(-)
which changes the commit object's contents.