# locate commit by file

2 messages from 2008-11-04 to 2008-11-04. Participants: Ittay Dror, Jakub Narebski.
Thread: https://gitlist.dev/t/16164

## Ittay Dror, 2008-11-04 08:11

Subject: locate commit by file
Message-ID: <491003BC.7040206@gmail.com>
URL: https://gitlist.dev/e/491003BC.7040206%40gmail.com

```
Hi,


Given a file, is there an easy way (e.g., not bisectig) to find the 
latest commit where the file content is the same?


Meaning: I have a file /tmp/A and I want to file the latest commit where 
a/b/A is identical (content wise) to /tmp/A.


Thank you,

Ittay


-- 
--
Ittay Dror <ittay.dror@gmail.com>

```

## Jakub Narebski, 2008-11-04 09:57

Subject: Re: locate commit by file
Message-ID: <m34p2ng6eq.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m34p2ng6eq.fsf%40localhost.localdomain
In-Reply-To: <491003BC.7040206@gmail.com>

```
Ittay Dror <ittay.dror@gmail.com> writes:

> Given a file, is there an easy way (e.g., not bisecting) to find the
> latest commit where the file content is the same?
> 
> Meaning: I have a file /tmp/A and I want to file the latest commit
> where a/b/A is identical (content wise) to /tmp/A.

Do you mean: find the commit which changed file to current version?
I think that

  $ git rev-parse -1 -- file

Would work (but better check "git log -- file").

If you want to find which version corresponds to given contents, you
would have to find sha-1 of /tmp/A (using "git hash-object"), and
find it in difftree searching for sha ("git log --raw -- file", or
just "git log --raw" if you are not sure about name).

I think you can fins such script in mailing list archives...
-- 
Jakub Narebski
Poland
ShadeHawk on #git

```
