How do I call git diff on the same file between 2 different local branches?

akantoword picture akantoword · Jul 29, 2016 · Viewed 32.1k times · Source

Is there a way to check the difference between the working directory in my current branch against the working directory of another branch in a specific file? For example, if I'm working in branch A on file 1, I want to compare the difference with file 1 on branch B.

Answer

Patrick Murphy picture Patrick Murphy · Jul 29, 2016

Use the git diff branch branch filename syntax:

git diff branchA branchB -- file.cs

put the two names of your branches and optionally use the -- filename option to specify one file! Good luck, let me know if you have issues.