Does `git archive` use the wrong file timestamp

gittimestamps

It seems git archive creates a tarball with wrong file modification timestamps, resulting in tar complaining when unpacking:

$ cd repository
$ git archive -o repository.tar.gz master .
$ find /target/dir -type f -delete
$ tar -C /target/dir -xvf repository.tar.gz
some/file.txt
tar: some/file.txt: time stamp 2014-10-29 13:09:52 is 49.814349986 s in the future
another/file.txt
tar: another/file.txt: time stamp 2014-10-29 13:09:52 is 49.813794938 s in the future

This all happens within seconds on a single machine.

Best Answer

When you give a commit ID or tag ID (or branch name, as you've done here) to git archive, the commit time as recorded in the referenced commit object is used as the modification time of each file in the archive.

It looks like the latest commit on master was at 2014-10-29 13:09:52, which must have been in the future relative to the moment when you ran git archive. Perhaps that commit was fetched from a remote repository with an incorrect clock, or the local clock is incorrect?

Related Question