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

Re: referencing a revision at a certain date

From
DMDavid Madore <david.madore@ens.fr>
Date
Feb 11, 2008, 18:57 UTC
Message-ID
<20080211185713.GA16898@clipper.ens.fr>
In-Reply-To
<m3r6fje3q8.fsf@localhost.localdomain>
On Mon, Feb 11, 2008 at 10:40:39AM -0800, Jakub Narebski wrote:
Show 8 quoted lines
> But you can can get commit closest to given date by combining the time
> limiting with limiting number of commits, as described in "Commit
> limiting" in git-rev-list(1) and git-log(1) manpages.
> 
>   $ git log -n 1 --before=<date> <branch>
> 
> which would return first commit older than <date>, starting from
> <branch>.

OK, thanks, I guess the --before part answers my question: so to get revision "rev" back at date "YYYY-MM-DD" (always using first parents) I'd do

git rev-list rev -n 1 --first-parent --before=YYYY-MM-DD
as in:
git checkout "`git rev-list rev -n 1 --first-parent --before=YYYY-MM-DD`"

It's a bit of a mouthful, but it does what I want (although I still think a syntax such as rev~@{YYYY-MM-DD} or rev~{YYYY-MM-DD} or whatever might prove useful: I imagine I'm not the first person to wish for something of the sort).

Thanks,
-- 
     David A. Madore
    (david.madore@ens.fr,
     http://www.madore.org/~david/ )
Previous: Jakub Narebski
Message 4 of 4 in “referencing a revision at a certain date”
  1. David MadoreFeb 11, 2008
  2. Jeff KingFeb 11, 2008
  3. Jakub NarebskiFeb 11, 2008
  4. David MadoreFeb 11, 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.