2

I am stuck on how to compare local files to files in remote repo.

See screenshot as an example.

I right-click on app.js Git > Compare with Branch

I selected origin/master (the remote repo to compare with). Phpstorm is reporting that there are no differences in the files. However, I know this is not the case.

In the screenshot, Item #1 (see arrow) is the remote file on bitbucket. Item #3 is the local file. Phpstorm is reporting no difference (Item #2).

enter image description here

UPDATE

I've learned the git command line commands for what I want to do. Thanks to @Shahbaz

Suppose I have local master and the remote origin/master

So, to see the difference between a local file index.js and the remote index.js, I'd do the following

$> git fetch origin
$> git diff master origin/master -- index.js

Maybe by providing the command line commands, someone can tell me the PhpStorm equivalent to get a graphical diff.

Community
  • 1
  • 1
Jordan
  • 159
  • 3
  • 14
  • Fetch latest changes from bitbucket to local repository. run `git pull` or `Ctrl+T` in phpstorm – funivan Dec 01 '15 at 06:31
  • @funivan I'm not trying to pull files to local repo (yet).I simply want to compare a local file to it's latest commit at the remote – Jordan Dec 01 '15 at 22:15

1 Answers1

3

In order to see a graphical diff between your local version of the file, and the latest remote version of the file, run the following two commands in sequence:

  1. VCS Menu > Git > Fetch
  2. VCS Menu > Git > Compare with Latest Repository Version

The important step here is actively fetching (rather than pulling) the most recent data from the remote repository. If you're interested, this will help explain in more detail: What is the difference between 'git pull' and 'git fetch'?

Community
  • 1
  • 1
Nate
  • 1,442
  • 14
  • 22
  • Thank you. That does what I want. And the link explaining the difference is helpful. To borrow an Adobe Lightroom analogy (I'm a photographer) it's kinda like RAW files and xml sidecar. Doing a fetch brings the remote as a sidecar to my working RAW code. Diff command then compares working and sidecar files . That's cool, but as a lay person, wouldn't the same thing be accomplished by comparing my working file to the actual remote; why the intermediate step of bringing the files down? Accepting your answer. Cheers! – Jordan Dec 03 '15 at 23:51
  • Cool, I'm glad it helped you. As for your question, "why the intermediate step of bringing the files down?" -- This is necessary because your local git repository isn't *automatically* informed of server-side changes. The only way you can be informed about any file changes on the remote server is to manually ask the server, "Hi again. Has anything has changed since the last time we spoke?". It would definitely be nice if PhpStorm provided the ability to abstract the 'fetch & diff' into a single UI command, but for the time being, you'll have to handle them both separately :) – Nate Dec 04 '15 at 00:12
  • Thanks again for the super quick reply and help. Since reading your linked I've studied more and see even command line there is not way to compare local with remote without doing a fetch first. I totally get you analogy, "Hi again. Has anything has changed since the last time we spoke?" Just seems strange there is not git command equivalent to something like: git diffremote master origin/master. In lay terms what I'm telling git is "Hey, it's me. Just calling to check if anything has changed since the last time we spoke? Don't worry about sending any data at them moment" :) – Jordan Dec 04 '15 at 22:01