Marc
Marc

Reputation: 14295

git diff to compare remote and local branches does nothing

I'm trying to view differences between my local master branch and the remote origin/master branch. I've read several such questions here and tried all the following options.

c:\>git diff master..origin/master

c:\>git diff origin/master master

c:\>git diff origin/master..master

c:\>git diff master origin/master

c:\>git log -p HEAD..FETCH_HEAD

Silence. Nothing.

I've tried them before and after doing git fetch and git fetch origin. To be clear: my local branch is different from the remote. git diff shows my changes.

Upvotes: 0

Views: 1179

Answers (1)

Schwern
Schwern

Reputation: 164809

To be clear: my local branch is different from the remote. git diff shows my changes.

If git diff is showing changes then your local branch likely isn't different from the remote because you haven't committed or even staged your changes yet.

git diff shows the difference between the working copy (ie. what's sitting on the disk) and the staging area. Various flags change what's being diffed. git diff --staged shows the difference between what you've staged and HEAD, it shows what is about to be committed.

WORKING COPY           STAGING AREA                    HEAD
       <--- git diff --->     <--- git diff --staged --->

I made a cheat sheet which illustrates this.

So if git diff is showing you have changes, those changes have not been staged nor committed. A git status should confirm.

To see what differences your working copy has vs origin/master use git diff origin/master.

Upvotes: 3

Related Questions