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.
Asked
Active
Viewed 1,002 times
1

Vaishak Suresh
- 5,735
- 10
- 41
- 66
1 Answers
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