Chaitanya Chaitanya - 6 months ago 75
Git Question

How to Diff between local uncommitted changes and origin

Let's say I cloned a repository and started modifying files. I know that if I have local uncommitted changes, I can do a diff as follows

git diff test.txt
and it will show me the difference between the current local HEAD and the modified, uncommitted changes in the file. If I commit those changes I can diff it against the original repository by using
git diff master origin/master

But is there any way of diff'ing the local changes with the original repository on the server before committing locally? I tried various permutations of
git diff --cached master origin/master
with no luck.


Given that the remote repository has been cached via git fetch it should be possible to compare against these commits. Try the following:

$ git fetch origin
$ git diff origin/master