1

How do I see the difference between a local file (in Master) and the same file in the remote repository (origin) in git? When I do a git fetch origin and then do a git diff master origin/master. It shows me a huge list of changes, which is not really helpful for a lot of java files.

Vaishak Suresh
  • 5,735
  • 10
  • 41
  • 66

1 Answers1

4

git diff master origin/master -- file/to/compare

The -- is a convention that many programs use; it indicates that any parameters after it are not to be considered options, even if they start with a hyphen. Git extends this convention and uses -- to indicate that the following parameters are files (and not branches or other refs, whose names may overlap with file names).

Actually, I believe the -- is optional as long as you do not use file names which also exist as branches etc., but it's easier to always use it.

Also see the git diff manpage. The "--" convention is explained in this question: Deleting a badly named git branch

Community
  • 1
  • 1
sleske
  • 81,358
  • 34
  • 189
  • 227