Change Commit Time

1

I would like to know if it is possible to change the time of a commit.

Situation is as follows, I have a git server integrated with redmine. When the users are going to upload code in the commit it gets the local time of the machine that is always wrong, I would like when the file is committed it will take the server time. I use a script to control the repository and actions in redmine.

Thank you in advance.

    
asked by anonymous 24.02.2016 / 15:47

1 answer

0

Use git filter-branch with a filter to change the field you want: GIT_AUTHOR_DATE or GIT_COMMITTER_DATE seem like the best options for your case.

If you want to make changes to commit 129g9ebd59069c366ab22f1f97d2b648faf932e0, you can do something like this:

git filter-branch --env-filter \
    'if [ $GIT_COMMIT = 129g9ebd59069c366ab22f1f97d2b648faf932e0]
     then
         export GIT_AUTHOR_DATE="Fri Jan 2 21:38:53 2009 -0800"
         export GIT_COMMITTER_DATE="Sat May 19 01:01:01 2007 -0700"
     fi'
    
24.02.2016 / 15:54