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

Re: How to query the version of a file?

From
TJTodd A. Jacobs <tjacobs@si2services.com>
Date
Aug 25, 2010, 13:27 UTC
Message-ID
<AANLkTi=_LaHnuZ7AYDW_TCD7fhSFFdcm_hX3GHRyvwEi@mail.gmail.com>
In-Reply-To
<AANLkTi=upbiD5EBumxNxG0YvSRZN0mDfvu7LeU0y0Zpw@mail.gmail.com>
On Wed, Aug 25, 2010 at 2:33 AM, Edmond Halley <halleyinvent@gmail.com> wrote:
Show 6 quoted lines
> I have a standalone repository.
> File a.cpp has 3 versions.
> For example, I checked out version2(HEAD^).
>> git checkout HEAD^ a.cpp
> After a few days, I forget which version I have checked out.
> Is there a git command that can query which version is checked out?

There may be an easier way to do this, but the way I do it is (sort of) documented in http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#Finding-comments-With-given-Content (should be "commits" instead of "comments", but oh well!) and can be tweaked to suit yourself:

    git log --raw --abbrev=40 --pretty=oneline |
    grep -B 24 `git hash-object a.cpp`

There may be other, and possibly more efficient, ways to do this, but it generally works for me.

Previous: Edmond HalleyNext: sandy2010
Message 2 of 5 in “How to query the version of a file?”
  1. Edmond HalleyAug 25, 2010
  2. Todd A. JacobsAug 25, 2010
  3. sandy2010Sep 28, 2010
  4. Michael J GruberSep 28, 2010
  5. Pascal ObrySep 28, 2010

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.