编辑:摘要:Git 不允许在 1973/03/03 09:46:40 (epoch+100000000s) 之前以其“内部日期格式”(自纪元以来的秒数)给出日期。这是为了允许“20110224”作为“2011-02-24”的缩写形式。--这不是错误:不是真的,但也没有记录。--解决方法:当你不能依赖 git 内部日期时,不要依赖它。--感谢:霍布斯
大家好,
我有一些关于 git filter-branch 的问题,我已经追踪到 git commit-tree。考虑这个脚本:
#!/bin/bash
# please run these commands in an empty directory
# (should not destroy an existing repo, though. I think it would only
# a few dangling objects)
set -e -o pipefail
git init
tree=$(git write-tree)
commit=$(echo "my first commit -- the tree is empty" |
env GIT_AUTHOR_DATE="0 +0000" git commit-tree $tree)
echo "This is commit $commit:"
git cat-file commit $commit
请注意,env GIT_AUTHOR_DATE="0 +0000"
使用“Git 内部格式”将日期设置为 1970-01-01。
但是这个脚本的输出(原始提交)是
tree 4b825dc642cb6eb9a060e54bf8d69288fbee4904
author Jane Doe <jane> 1298477214 +0100
committer Jane Doe <jane> 1298477214 +0100
my first commit -- the tree is empty
现在为什么 git 忽略 $GIT_AUTHOR_DATE?如果这很重要,我git --version
会给git version 1.7.1
.