Dogbert Dogbert - 7 months ago 37
Git Question

diff current working copy of a file with another branch's committed copy

I have a repo with file

in the master branch. I switch to a branch
and make some changes to
. How can I now run a
git diff
between this copy (which isn't committed yet) and the copy of the master branch?


The following works for me:

git diff foo master:foo

Update: However, I should confess that I often get very confused by swapping the arguments around, to:

git diff master:foo foo

... and it doesn't work, giving the error:

fatal: Path 'foo' exists on disk, but not in 'master'.