git whatchanged -n 1 -p <file>

without the -n 1 you'll get a history of all the patches to the file.

On Tue, Sep 23, 2008 at 8:39 PM, [EMAIL PROTECTED] <[EMAIL PROTECTED]>wrote:

> Is there an easy way to say "diff against the most recent commit that
> affected this file"? If I do git diff HEAD^ <file>, it diffs against
> the previous commit to the repository as a whole, but that commit may
> not have affected <file>. For example, I may commit to file changes to
> file X, commit changes to file Y, then commit changes to file Z. If I
> want to diff file X against the previous revision of file X, I'd have
> to do 'git diff HEAD~3' (or manually look through the log for the
> commit id), but that assumes I know that the previous commit that
> affected file X was 3 commits ago.
> >

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To post to this group, send email to
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at

Reply via email to