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

Re: diff/Checking out by date specification

From
Jeff King <peff@peff.net>
Date
Jun 30, 2008, 05:21 UTC
Message-ID
<20080630052105.GA21954@sigill.intra.peff.net>
In-Reply-To
<48686339.60205@rea-group.com>
On Mon, Jun 30, 2008 at 02:38:17PM +1000, Toby Corkindale wrote:
Show 7 quoted lines
> I think it would be good if you could give a couple of examples, such as:
> How would I go about checking out the code at the state it was in at,  
> say, 2008-01-01?
> Or how one can get a diff between 2008-01-01 and 2008-01-08?
>
> (I note that "git-diff --until=2008-01-08 --since=2008-01-01" fails, as  
> does "git-checkout --until=2008-01-08")

That is a little bit trickier, since there is a not a convenient syntax for selecting a particular revision by commit time. So you _can_ do this:

  git diff \
    `git rev-list -1 --until=2008-01-01 HEAD` \
    `git rev-list -1 --until=2008-01-08 HEAD`

But that isn't quite what you want either. Remember that history can follow many branches simultaneously. So what we are saying with "--until" here is "show me all the commits that happened before this time", and then we use "-1" to say "pick the first one." So you are really picking two points in time that are close to what you want, and then diffing the two states.

Depending on what you want to do, that may be enough. But more likely, you are interested in the actual shape of history, so looking at the individual commits with something like "gitk --since=2008-01-01 --until=2008-01-08" is probably going to be more instructive.

-Peff
Previous: Daniel BarkalowNext: Jeff King
Message 5 of 6 in “diff/Checking out by date specification”
  1. Toby CorkindaleJun 30, 2008
  2. Jeff KingJun 30, 2008
  3. Toby CorkindaleJun 30, 2008
  4. Daniel BarkalowJun 30, 2008
  5. Jeff KingJun 30, 2008
  6. Jeff KingJun 30, 2008

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.