Skip to contentSkip to conversation

Reverting/cheout files with old modification date

DISCUSSION Peter Pientka 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,
Is any way to revert/checkout some files from reposotory with old modification date(file parameter). Now, while I revert/checkout some file, modification date of file is set to current date and time.

Currently I`m using git version 1.7.4.msysgit.0

Thanks for reply

#1 lore raw
Quoted 5 lines · Peter Pientka

Hi,
Is any way to revert/checkout some files from reposotory with old modification date(file parameter). Now, while I revert/checkout some file, modification date of file is set to current date and time.

I use this hook. On checkout it sets the mtime of all the files to the date of the last commit touching them.

===== .git/hooks/post-checkout

#!/bin/sh

for f in git ls-tree --name-only -r HEAD; do

    mtime=`git log -n1 --date=iso --pretty=%ai -- $f`
    touch -m -d "$mtime" $f

done

=====

Signature · 5 lines
Fabrizio Chiarello <[email protected]>

You ask: what is the meaning or purpose of life? I can only answer with
another question: do you think we are wise enough to read God's mind?
  -- Freeman Dyson