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?
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?
 
    
    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 <dustin@spy.net>
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).
 
    
    You can amend the commit, an example with the year 2037:
git commit --amend --date="Wed Feb 16 14:00 2037 +0100"
I tried the year 2038 too but then I got a null value for the date.
 
    
    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.
 
    
    By combining Hugo's answer (1) with information found over here (2), and tossing in some sed, I got this:
alias newest="find . -path ./.git -prune -o -type f -exec stat -c \"%y %n\" '{}' + | sort -r | head -1 | sed s#'.*\./'##"
GIT_AUTHOR_DATE="$(newest | xargs date -u -r)" GIT_COMMITTER_DATE="$(newest | xargs date -u -r)" git commit -m "Old sources retaining old change-dates of last changed file: $(newest), actual commit date: $(date)"
The main difference is that this version does a recursive search, so you get the latest file anywhere in the tree - though it does skip the .git directory, intentionally.
You may, of course, want to drop one of the date variables here, and I am using a fairly recent version of bash (4.2.37(1)-release), so the $() notation might not work for you (just replace it with backticks (`) instead).
 
    
     
    
    If you want to amend a commit with a date "from the future" as in this answer:
git commit --amend --date="Wed Feb 16 14:00 2037 +0100"
See commit 1820703 (21 Aug 2018) by Derrick Stolee (derrickstolee).
(Merged by Junio C Hamano -- gitster -- in commit 1392c5d, 27 Aug 2018) 
commit: usetimestamp_tforauthor_date_slabThe
author_date_slabis used to store the author date of a commit when walking with the--author-dateflag in rev-list or log.
This was added as an 'unsigned long' in 81c6b38 ("log:--author-date-order", June 2013, Git 1.8.4-rc0)Since '
unsigned long' is ambiguous in its bit-ness across platforms (64-bit in Linux, 32-bit in Windows, for example), most references to the author dates incommit.cwere converted totimestamp_tin dddbad7 ("timestamp_t: a new data type for timestamps", April 2017, Git 2.14.0-rc0)However, the slab definition was missed, leading to a mismatch in the data types in Windows.
This would not reveal itself as a bug unless someone authors a commit after February 2106, but commits can store anything as their author date.
 
    
    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.
