Change Time of Commit

Asked

Viewed 728 times

1

I wonder if it’s possible to change the time of a commit.

Here’s the situation, I have a built-in git server with Redmine. When users are going to upload code in the commit gets the local time of the machine that is always wrong, I would like when the file is commited it takes the server time. I use a script to control the repository and actions in Redmine.

Grateful from now on.

1 answer

0


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

If you want to make changes to the 129g9ebd59069c366ab22f1f97d2b648faf932e0 commit, 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'
  • Well I would like it to be automatic, every time a commit is made the time and date will be changed, being the same as the server.

  • 1

    Git allows the creation of "Hooks" on both the Server and Client side to call a script and do some action when important events happen, such as in the case of a commit (on the client) or push (on the server).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.