git diff can show you the difference between two commits:
git diff mybranch master -- myfile.cs
git diff mybranch..master -- myfile.cs
Note you must specify the relative path to the file. So if the file were in the src directory, you’d say
src/myfile.cs instead of
Using the latter syntax, if either side is
HEAD it may be omitted (e.g.,
You may also be interested in
git diff documentation):
This form is to view the changes on the branch containing and up to the second
<commit>, starting at a common ancestor of both
git diff A...Bis equivalent to
git diff $(git-merge-base A B) B.
In other words, this will give a diff of changes in
master since it diverged from
mybranch (but without new changes since then in
In all cases, the
-- separator before the file name indicates the end of command line flags. This is optional unless Git will get confused if the argument refers to a commit or a file, but including it is not a bad habit to get into. See Dietrich Epp’s answer to Meaning of Git checkout double dashes for a few examples.
The same arguments can be passed to
git difftool if you have one configured.