Re: how to diff versions of a file

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

Re: how to diff versions of a file

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:46:05

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...

Re: how to diff versions of a file

From: Matt Graham <hidden>
Date: 2016-06-15 22:46:05

On Tue, Feb 3, 2009 at 01:34, Junio C Hamano [off-list ref] wrote:
david@lang.hm writes:
quoted
I don't think it's trivial
I think you meant to say it _is_ trivial.
quoted
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".
quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help