# How to query the version of a file?

5 messages from 2010-08-25 to 2010-09-28. Participants: Edmond Halley, Todd A. Jacobs, sandy2010, Michael J Gruber, Pascal Obry.
Thread: https://gitlist.dev/t/24855

## Edmond Halley, 2010-08-25 06:33

Subject: How to query the version of a file?
Message-ID: <AANLkTi=upbiD5EBumxNxG0YvSRZN0mDfvu7LeU0y0Zpw@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3DupbiD5EBumxNxG0YvSRZN0mDfvu7LeU0y0Zpw%40mail.gmail.com

```
Hi,

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?
"git status" will show there is "changes to be committed", but with no
the version information.
Thank you!

Best regards,
Halley

```

## Todd A. Jacobs, 2010-08-25 13:27

Subject: Re: How to query the version of a file?
Message-ID: <AANLkTi=_LaHnuZ7AYDW_TCD7fhSFFdcm_hX3GHRyvwEi@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3D_LaHnuZ7AYDW_TCD7fhSFFdcm_hX3GHRyvwEi%40mail.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:
> 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.

```

## sandy2010, 2010-09-28 10:49

Subject: Re: How to query the version of a file?
Message-ID: <1285670986056-5578850.post@n2.nabble.com>
URL: https://gitlist.dev/e/1285670986056-5578850.post%40n2.nabble.com
In-Reply-To: <AANLkTi=upbiD5EBumxNxG0YvSRZN0mDfvu7LeU0y0Zpw@mail.gmail.com>

```

I do not see the reply to this thread. I'm unable to find how to find the
version of a checked out file? Also, how do I view an older version?
-- 
View this message in context: http://git.661346.n2.nabble.com/How-to-query-the-version-of-a-file-tp5459953p5578850.html
Sent from the git mailing list archive at Nabble.com.

```

## Michael J Gruber, 2010-09-28 11:19

Subject: Re: How to query the version of a file?
Message-ID: <4CA1CF2F.3050903@drmicha.warpmail.net>
URL: https://gitlist.dev/e/4CA1CF2F.3050903%40drmicha.warpmail.net
In-Reply-To: <1285670986056-5578850.post@n2.nabble.com>

```
sandy2010 venit, vidit, dixit 28.09.2010 12:49:
> 
> I do not see the reply to this thread. I'm unable to find how to find the
> version of a checked out file? Also, how do I view an older version?

Todd already answered to your address as well as to the list (3 days
ago). Your 2nd question is answered in the same place he pointed you to:

http://www.kernel.org/pub/software/scm/git/docs/user-manual.html#viewing-old-file-versions

Now, what do you think is the top hit when googling "git view older
version" ;)

Michael

```

## Pascal Obry, 2010-09-28 11:26

Subject: Re: How to query the version of a file?
Message-ID: <AANLkTi=pTdLA=KerZnNyfWZdWJNHE5xFWarzHQpBpDu_@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTi%3DpTdLA%3DKerZnNyfWZdWJNHE5xFWarzHQpBpDu_%40mail.gmail.com
In-Reply-To: <1285670986056-5578850.post@n2.nabble.com>

```
On Tue, Sep 28, 2010 at 12:49 PM, sandy2010 <sandeeptt@yahoo.com> wrote:
> I do not see the reply to this thread. I'm unable to find how to find the
> version of a checked out file? Also, how do I view an older version?

No response probably because there is no notion of version of a file in Git.

Each commit is uniquely identified (SHA-1). A file is part of a commit.

I would recommend to read some Git tutorials, books that can be found
on the Web. See Git wiki, or the online Pro Git book:

   http://progit.org/book/

Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|              http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595

```
