# date change of commit?

7 messages from 2009-10-25 to 2009-10-29. Participants: Alex K, Matthieu Moy, Miklos Vajna, Rogan Dawes, Thomas Rast.
Thread: https://gitlist.dev/t/21348

## Alex K, 2009-10-25 11:35

Subject: date change of commit?
Message-ID: <e4a904790910250435p3ff50dcfv5c0c6a86c13d17b@mail.gmail.com>
URL: https://gitlist.dev/e/e4a904790910250435p3ff50dcfv5c0c6a86c13d17b%40mail.gmail.com

```
Hello,

Is it possible to change the date of a commit?

Thank you,

Alex

```

## Matthieu Moy, 2009-10-25 17:14

Subject: Re: date change of commit?
Message-ID: <vpq1vkrqttt.fsf@bauges.imag.fr>
URL: https://gitlist.dev/e/vpq1vkrqttt.fsf%40bauges.imag.fr
In-Reply-To: <e4a904790910250435p3ff50dcfv5c0c6a86c13d17b@mail.gmail.com>

```
Alex K <spaceoutlet@gmail.com> writes:

> Hello,
>
> Is it possible to change the date of a commit?

See git-filter-branch. This won't change the date of the existing
commit (which is impossible in Git), but will create another commit
where only the date has been changed.

-- 
Matthieu Moy
http://www-verimag.imag.fr/~moy/

```

## Alex K, 2009-10-27 09:41

Subject: Re: date change of commit?
Message-ID: <e4a904790910270241g4a165023o30438c5d000b5de4@mail.gmail.com>
URL: https://gitlist.dev/e/e4a904790910270241g4a165023o30438c5d000b5de4%40mail.gmail.com
In-Reply-To: <vpq1vkrqttt.fsf@bauges.imag.fr>

```
Thank you. And how would you use git-filter-branch to create another
branch with a different time stamp? Is it possible to commit under a
different time stamp than the one provided by your default local time?

2009/10/25 Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>:
> Alex K <spaceoutlet@gmail.com> writes:
>
>> Hello,
>>
>> Is it possible to change the date of a commit?
>
> See git-filter-branch. This won't change the date of the existing
> commit (which is impossible in Git), but will create another commit
> where only the date has been changed.
>
> --
> Matthieu Moy
> http://www-verimag.imag.fr/~moy/
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>

```

## Miklos Vajna, 2009-10-27 12:21

Subject: Re: date change of commit?
Message-ID: <20091027122156.GD6115@genesis.frugalware.org>
URL: https://gitlist.dev/e/20091027122156.GD6115%40genesis.frugalware.org
In-Reply-To: <e4a904790910270241g4a165023o30438c5d000b5de4@mail.gmail.com>

```
On Tue, Oct 27, 2009 at 10:41:47AM +0100, Alex K <spaceoutlet@gmail.com> wrote:
> Thank you. And how would you use git-filter-branch to create another
> branch with a different time stamp? Is it possible to commit under a
> different time stamp than the one provided by your default local time?

You can set GIT_AUTHOR_DATE and GIT_COMMITTER_DATE. Both expect a format
like: "1112911993 -0700" (unix timestamp + timezone info).

```

## Alex K, 2009-10-29 12:55

Subject: Re: date change of commit?
Message-ID: <e4a904790910290555n61bca296g3624c1aced50ed85@mail.gmail.com>
URL: https://gitlist.dev/e/e4a904790910290555n61bca296g3624c1aced50ed85%40mail.gmail.com
In-Reply-To: <20091027122156.GD6115@genesis.frugalware.org>

```
And how do you actually set those variables? Sorry to ask such a
trivial question but it's been an hour that i'm going through the doc
for such a simple feature. I thought those were environment variables
... but they are not seen under git var -l. Thank you.

2009/10/27 Miklos Vajna <vmiklos@frugalware.org>:
> On Tue, Oct 27, 2009 at 10:41:47AM +0100, Alex K <spaceoutlet@gmail.com> wrote:
>> Thank you. And how would you use git-filter-branch to create another
>> branch with a different time stamp? Is it possible to commit under a
>> different time stamp than the one provided by your default local time?
>
> You can set GIT_AUTHOR_DATE and GIT_COMMITTER_DATE. Both expect a format
> like: "1112911993 -0700" (unix timestamp + timezone info).
>

```

## Rogan Dawes, 2009-10-29 14:47

Subject: Re: date change of commit?
Message-ID: <4AE9AAE7.2080404@dawes.za.net>
URL: https://gitlist.dev/e/4AE9AAE7.2080404%40dawes.za.net
In-Reply-To: <e4a904790910290555n61bca296g3624c1aced50ed85@mail.gmail.com>

```
Alex K wrote:
> And how do you actually set those variables? Sorry to ask such a
> trivial question but it's been an hour that i'm going through the doc
> for such a simple feature. I thought those were environment variables
> ... but they are not seen under git var -l. Thank you.
> 

As you suspected, they are environment variables.

i.e. :

$ GIT_AUTHOR_DATE="1112911993 -0700" git commit x

Hope that helps.

Rogan

> 2009/10/27 Miklos Vajna <vmiklos@frugalware.org>:
>> On Tue, Oct 27, 2009 at 10:41:47AM +0100, Alex K <spaceoutlet@gmail.com> wrote:
>>> Thank you. And how would you use git-filter-branch to create another
>>> branch with a different time stamp? Is it possible to commit under a
>>> different time stamp than the one provided by your default local time?
>> You can set GIT_AUTHOR_DATE and GIT_COMMITTER_DATE. Both expect a format
>> like: "1112911993 -0700" (unix timestamp + timezone info).
>>

```

## Thomas Rast, 2009-10-29 16:43

Subject: Re: date change of commit?
Message-ID: <200910291743.53701.trast@student.ethz.ch>
URL: https://gitlist.dev/e/200910291743.53701.trast%40student.ethz.ch
In-Reply-To: <4AE9AAE7.2080404@dawes.za.net>

```
Rogan Dawes wrote:
> Alex K wrote:
> > And how do you actually set those variables? Sorry to ask such a
> > trivial question but it's been an hour that i'm going through the doc
> > for such a simple feature. I thought those were environment variables
> 
> As you suspected, they are environment variables.
> 
> i.e. :
> 
> $ GIT_AUTHOR_DATE="1112911993 -0700" git commit x

Since this was in the context of git-filter-branch, I should point out
that you'll have to use the variables with --env-filter and (like the
manpage says) make sure you export them.

So to change the date of a single commit with SHA1 <sha1>, you could
say

git filter-branch --env-filter '
  if [ $GIT_COMMIT = <sha1> ]; then
    export GIT_AUTHOR_DATE="1112911993 -0700"
    export GIT_COMMITTER_DATE="1112911993 -0700"
  fi
' <other_arguments>

Alex K wrote:
> for such a simple feature

I'm not sure if you're referring to setting the variables or actually
rewriting the commits here, but anyway:

The reason why the latter is so hard is that rewriting "old" history
is a _huge_ hassle for people who already have the previous version of
that history.

That being said, _why_?  The dates are never a guarantee that
something happened earlier or later precisely because they can easily
be modified at commit time.  So nobody should take them as more than a
hint, and there's little use in faking hints.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

```
