How to keep local file date and time when pushing to GitHub

Go To StackoverFlow.com

5

I would like to push one of my old archived projects up to GitHub and I'd like to keep the original file date (27/08/2011). Is it possible? Thanks.

2012-04-05 18:45
by Kalman Speier


1

Each commit stores the date the commit has been authored and the date the commit has been committed into the repository.

Performing a git log --format=fuller operation of a repository will print those dates.

When you push to GitHub, those commits are being pushed unmodified, with all their meta-data information. Thus the dates those commits have been performed on will be preserved.

2012-04-05 20:21
by nulltoken
Thanks! In the meantime I found that I have to specify or amend the commit date. Do you know how can I do that - Kalman Speier 2012-04-05 20:24
Something like git commit --amend --date="Wed Feb 16 14:00 2037 +0100" should do the trick. See the documentation for a more in-depth explanation - nulltoken 2012-04-05 20:44
See also http://stackoverflow.com/q/45473 - nulltoken 2012-04-05 20:46
The following almost did the trick:

SET GIT_AUTHOR_DATE="2011-08-27T21:48:00" SET GIT_COMMITTER_DATE="2011-08-27T21:48:00" git commit -m "archive"

GitHub says last commit was 7 months ago, but the repository is updated "just now". Hmm, anyway doesn't worth to spend more time on this. Thanks for your help - Kalman Speier 2012-04-05 21:17

"just now" refers to the lastest push date. It only relates to the repository activity from the GitHub standpoint - nulltoken 2012-04-05 21:34
Ads