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

Re: how to diff versions of a file

From
Matt Graham <mdg149@gmail.com>
Date
Feb 3, 2009, 13:48 UTC
Message-ID
<1c5969370902030548g284e8ae2i7dc3a866c4337a5f@mail.gmail.com>
In-Reply-To
<7vk588do5q.fsf@gitster.siamese.dyndns.org>
On Tue, Feb 3, 2009 at 01:34, Junio C Hamano <gitster@pobox.com> wrote:
Show 20 quoted lines
> david@lang.hm writes:
>
>> I don't think it's trivial
>
> I think you meant to say it _is_ trivial.
>
>> If you just wanted three commits ago you could do
>>
>> git diff HEAD..HEAD^^^ tree.c
>
> That would give you a reverse diff; I think you probably meant the other
> way around, "git diff HEAD~3 HEAD tree.c".
>
>> but three changes to tree.c ago I think you need to do multiple
>> iterations of git blame to find out what commit was three edits ago.
>
> git diff $(git rev-list -3 HEAD -- tree.c | sed -n -e '$p') HEAD -- tree.c
>
> This assumes that the history is linear but your statement "three edits
> ago" already assumes that, so...
Thanks Junio, this is exactly what I was asking for.
And thanks for the tip about it depending on the history being linear.
Previous: Junio C HamanoNext: Jeff King
Message 4 of 5 in “how to diff versions of a file”
  1. Matt GrahamFeb 3, 2009
  2. david@lang.hmFeb 3, 2009
  3. Junio C HamanoFeb 3, 2009
  4. Matt GrahamFeb 3, 2009
  5. Jeff KingFeb 3, 2009

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.