I started to move the content of my home directory to git repositories and stumbled upon a difficult difference between rsync and git: git does not preserve timestamps. This makes sense for code-repositories but if I replicate my home directory I expect that modification times are not always set to the current time.

I found this useful script (which I called 'git-utime') to set modifcation times to the timestamp of the commit which last touched a file. As far as I understand this is the best we have because git does not store the original timestamp when a file is commited (right?):


I bet there is some hook to install the script to be called on every pull - I think of a .gitutime file like .gitignore that selects all files that should get their original timestamp. If some of you already have such a system please let me know!

But git-utime is only one side of the process. How do I

1) reset the commit time of selected files in the repository to their last modification timestamp (for the files that I have already commited)

2) add and commit a set of files in a batch such that each commit has the timestamp of the last modification time of its file (for new files).

Obviously each commit must be only one file. The commit message could just be "initial commit" or "initial commit at `date --rfc-3339=s`".

Maybe by some additional git magic the .gitutime could be reused to give a warning if I try to add a new file that the normal way which would makes it impossible to preserve timestamp.

How do you deal with timestamp of you files? I heard there are some hacks to even preserve file permissions but I'd prefer a simple solution first.


Jakob Voß <jakob.v...@gbv.de>, skype: nichtich
Verbundzentrale des GBV (VZG) / Common Library Network
Platz der Goettinger Sieben 1, 37073 Göttingen, Germany
+49 (0)551 39-10242, http://www.gbv.de
vcs-home mailing list

Reply via email to