The git diff command displays the differences between files in two commits or between a commit and your current repository. You can see what text has been added to, removed from, and changed in a file. By default, the git diff command displays any uncommitted changes to your repository.
The git fetch command will fetch all changes that happened in the origin. And the git diff will show us the differents files between our working tree and the remote.
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
I know it's not an answer to the exact question asked, but I found this question looking to diff a file in a branch and a local uncommitted file and I figured I would share
Syntax:
git diff <commit-ish>:./ -- <path>
Examples:
git diff origin/master:./ -- README.md
git diff HEAD^:./ -- README.md
git diff stash@{0}:./ -- README.md
git diff 1A2B3C4D:./ -- README.md
(Thanks Eric Boehs for a way to not have to type the filename twice)
To see non-staged (non-added) changes to existing files
git diff
Note that this does not track new files. To see staged, non-commited changes
git diff --cached
If you want to compare files visually you can use:
git difftool
It will start your diff app automatically for each changed file.
PS: If you did not set a diff app, you can do it like in the example below(I use Winmerge):
git config --global merge.tool winmerge
git config --replace --global mergetool.winmerge.cmd "\"C:\Program Files (x86)\WinMerge\WinMergeU.exe\" -e -u -dl \"Base\" -dr \"Mine\" \"$LOCAL\" \"$REMOTE\" \"$MERGED\""
git config --global mergetool.prompt false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With