Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot git diff. File exists in both branches but getting "fatal: Path '...' exists on disk, but not in 'master'"?

Tags:

git

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.

like image 806
PatPeter Avatar asked Nov 08 '22 18:11

PatPeter


1 Answers

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.

like image 59
VonC Avatar answered Nov 15 '22 05:11

VonC