Hi,
I need to make some commits using Git but I would like the timestamp in git-log to be in the future.
How can I do a commit in git that causes a future timestamp to register in the git-log?
Thanks
Git-noob
Hi,
I need to make some commits using Git but I would like the timestamp in git-log to be in the future.
How can I do a commit in git that causes a future timestamp to register in the git-log?
Thanks
Git-noob
I can't imagine this is a normal use-case. One way to do it would be to temporarily set the time on your local computer to a future date and perform the commit, but that is disruptive and may cause problems with other tools that read the repository and unexpectedly see a future date in a commit.
You may want to reevaluate the reasons that you need to do this.
Did you try changing your clock? =)
I'd think that should work locally, but not sure what'd happen when others go to merge.
May I ask why you would want to do this?
If you don't want to change your clock, I would suggest creating a script to do the commit and use the Windows Scheduler (or whatever equivalent for your OS) to run the script at the time you want the commit to be.
You should wait a bit.
Or you can do this:
/tmp/x 604% env GIT_AUTHOR_DATE='Wed Dec 19 15:14:05 2029 -0800' git commit -m 'future!'
[master]: created 6348548: "Future!"
1 files changed, 1 insertions(+), 0 deletions(-)
/tmp/x 605% git log
Author: Dustin Sallings <[email protected]>
Date: Wed Dec 19 15:14:05 2029 -0800
Future!
Note that there's both an author date and a committer date, so be sure to set the right one (or both).
If you want to retain an actual change-date when adding a project to git, you can do so with
env GIT_AUTHOR_DATE="`ls -rt *.cpp|tail -1|xargs date -u -r`" git commit -m "Old sources retaining old change-dates of last changed
file: `ls -rt *.cpp|tail -1`, actual commit date: `date`"
This will commit with the change-date of the last-changed *.cpp-file, and a nice explaining message of the actual commit date.