Reputation: 101
I have some files in my Git repository:
...
-rw-r--r-- 1 dimti dimti 11489 мар 2 21:54 wp-settings.php
...
After executing the command
git archive --format=tar HEAD > repo.tar
I fetch my files in the tar archive, but the modify time is wrong:
-rw-r--r-- 1 dimti dimti 11115 мар 5 21:55 wp-settings.php
How can I say to Git archive - preserve the modification time on files in the tar archive?
Upvotes: 1
Views: 961
Reputation: 1322835
You can try and tag it first, in order to use that tag, or use the commit ID
The git archive
man page mentions:
git archive
behaves differently when given a tree ID versus when given a commit ID or tag ID.
- In the first case (tree ID like HEAD) the current time is used as the modification time of each file in the archive.
- In the latter case (commit ID or tag ID) the commit time as recorded in the referenced commit object is used instead.
So in your case (using "How to retrieve the hash for the current commit in Git?"):
git archive --format=tar $(git rev-parse HEAD) > repo.tar
Upvotes: 3