6

This is what I get when trying to compare a file between a branch and master:

git diff gamemodes/terrortown/entities/entities/ttt_c4/shared.lua  
         master:gamemodes/terrortown/entities/entities/ttt_c4/shared.lua

fatal: Path 'gamemodes/terrortown/entities/entities/ttt_c4/shared.lua' 
       exists on disk, but not in 'master'.

Here is the file on master:

$ git log -n 1 -- gamemodes/terrortown/entities/entities/ttt_c4/shared.lua
commit d0241471298ce617b68dcf268be1c0af0cf8170c
Author: me
Date:   Fri Jan 1 23:25:17 2016 -0600

    December 2015 Update

And here is the file on my branch real_disarm:

$ git log -n 1 -- gamemodes/terrortown/entities/entities/ttt_c4/shared.lua
commit 84a7de46b92b8747cf98a57a8f7101682377980e
Author: me
Date:   Sun Jan 10 00:27:33 2016 -0600

    Remove trailing whitespace

Obviously the file exists in both branches. The whole reason I'm comparing the files is because I'm trying to remove trailing whitespace so that my patches don't give annoying "warning: squelched 5 whitespace errors warning: 10 lines add whitespace errors." output.

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
PatPeter
  • 394
  • 2
  • 17
  • 1
    Does `git diff ..master -- gamemodes/terrortown/entities/entities/ttt_c4/shared.lua` has the same issue? – VonC Mar 06 '16 at 08:36
  • I never before seen this way of using `diff` command. I can't see it [in documentation too](https://git-scm.com/docs/git-diff). – Marek R Mar 06 '16 at 09:52
  • @MarekR [This](http://stackoverflow.com/a/9113407) is where I got the comparison functionality from. – PatPeter Mar 06 '16 at 18:38
  • That seems to have worked @VonC! Do you mind if I ask what `..master` means? I know that `--` indicates an end to command arguments. Also, if you put it in an answer I'll accept it. – PatPeter Mar 06 '16 at 18:54

1 Answers1

1

You can find different ways to compare a file with itself from another branch in "How can I compare files from two different branches?".

In your case:

git diff ..master -- gamemodes/terrortown/entities/entities/ttt_c4/shared.lua

See Mark Longair's answer about "What are the differences between double-dot “..” and triple-dot “…” in git diff commit ranges?"

..master will show the difference between the tip of the current branch (HEAD) and master.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250