为什么相同的git脚本产生不同的哈希?

and*_*ref 5 git hash

我正在编写一个脚本作为Git用法的一个例子.但是,每次运行它时,即使提交消息,作者,日期,父级和内容相同,也会生成一组不同的哈希值:

rm -rf /tmp/git-teste
git init /tmp/git-teste
cd /tmp/git-teste
echo 'zero' > master.txt
git add .
git commit -am zero --date '2013-05-28 16:40:00' --author 'andre <teste@teste.com>'
Run Code Online (Sandbox Code Playgroud)

哈希不应该总是一样吗?我应该改变什么以确保这种情况发生?

Fre*_*Foo 6

Git提交有两个日期:您设置的作者日期commit --date和提交日期.两者都用于计算SHA1.可以使用GIT_COMMITTER_DATE环境变量设置提交日期,请参阅git help commit-tree.