# Reverting/cheout files with old modification date

2 messages from 2011-06-09 to 2011-06-10. Participants: Peter Pientka, Fabrizio Chiarello.
Thread: https://gitlist.dev/t/27590

## Peter Pientka, 2011-06-09 07:09

Subject: Reverting/cheout files with old modification date
Message-ID: <loom.20110609T090306-164@post.gmane.org>
URL: https://gitlist.dev/e/loom.20110609T090306-164%40post.gmane.org

```
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

```

## Fabrizio Chiarello, 2011-06-10 07:17

Subject: Re: Reverting/cheout files with old modification date
Message-ID: <20110610071707.GA4715@hydrogen.black.hole>
URL: https://gitlist.dev/e/20110610071707.GA4715%40hydrogen.black.hole
In-Reply-To: <loom.20110609T090306-164@post.gmane.org>

```
On Thu, Jun 09, 2011 at 07:09:47AM +0000, Peter Pientka wrote:
> 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

=====


-- 
Fabrizio Chiarello <fabrizio.chiarello@ieee.org>

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

```
