Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

avoid timestamps in git

Tags:

git

github

How can you systematically set git up to set all timestamps to be at some arbitrary point e.g. 1970-01-01 or something?

Are timestamps ever used, or are they just trivia that it is safe to anonymize?

like image 300
Will Avatar asked Jan 20 '23 05:01

Will


1 Answers

I really have no idea why one would want to do this, but for creating new commits with commit and author date set to that date and time, you can do:

export GIT_AUTHOR_DATE="1970-01-01T00:00:00"
export GIT_COMMITTER_DATE="1970-01-01T00:00:00"

To rewrite all the old dates in the repository you can easily modify the example here:

  • How can one change the timestamp of an old commit in Git?

... to rewrite every commit with those dates. Note that this will change the object name (SHA1sum) of every commit, of course.

As for whether the dates are "trivia" - they certainly aren't to me! It's frequently useful to know when a commit was made, and not just its position in the commit graph. Also, less seriously, gource needs those data for its beautiful animations of your repository history ;)

like image 86
Mark Longair Avatar answered Jan 27 '23 06:01

Mark Longair