6

I need to understand changes to a file between two releases represented by my current master and branch new_branch. Normally, I would run the following if path/name are the same in both branches.

git diff new_branch -- path/file

What do I do when path/file is different between the two branches?

I can fallback and create another cloned repository and checkout new_branch. Then do unix's sdiff. I was just wondering if the authors of git diff anticipated this scenario and built something in to handle it.

--Thank you, --Mike Jr.

1

1 Answer 1

5

Git has no real notion of moved/renamed/copied files, however it has heuristics to try and detect those cases and then display them in a nice way.

That said, you can instruct git-diff to use those heuristics to detect renames by passing it the -M flag. With that you can try

git diff -M new_branch -- new-path/file old-path/file

and see if it works in your specific case. Further, git diff -M --stat new_branch will give you an overview of the changes, and also show you what renames Git's heuristics picked up.

1
  • Perfect. Worked like a champ. I wish the git-diff man page had included your example.
    – Mike Jr
    Aug 6, 2010 at 14:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .