Tom Tanner
Tom Tanner

Reputation: 9354

How can I get git to show me changes on an individual renamed file

If I do

git difftool -y --find-renames master

I get diffs of any file with the original version on the branch, so if I've renamed 'a' to 'b' and changed it, I get the differences between the current 'b' and the original 'a'. But if, instead, I do

git difftool -y --find-renames master b

it gets compared with /dev/null. This is quite confusing.

Is there any way to get git diff to do what I expect?

Upvotes: 2

Views: 283

Answers (1)

mockinterface
mockinterface

Reputation: 14890

You can always be explicit about your comparison,

$ git diff master:a b

The -M (find-renames) and the -C are heuristics, and in your case you know that it was a that was explicitly renamed to b.

If a and b are not known in advance you can leverage your first command to get a list of suggestions first, followed by an excursion into the file histories:

$ git diff --find-renames --name-only master

invoking log --follow on every suspected rename:

$ git log --follow <renamed file>

Upvotes: 2

Related Questions