git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: date change of commit?

From
Thomas Rast <trast@student.ethz.ch>
Date
Oct 29, 2009, 16:43 UTC
Message-ID
<200910291743.53701.trast@student.ethz.ch>
In-Reply-To
<4AE9AAE7.2080404@dawes.za.net>
Rogan Dawes wrote:
Show 10 quoted lines
> 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
Previous: Rogan Dawes
Message 7 of 7 in “date change of commit?”
  1. Alex KOct 25, 2009
  2. Matthieu MoyOct 25, 2009
  3. Alex KOct 27, 2009
  4. Miklos VajnaOct 27, 2009
  5. Alex KOct 29, 2009
  6. Rogan DawesOct 29, 2009
  7. Thomas RastOct 29, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.