1

I would like to diff a particular file between 2 branches. I saw there is a difftool. But I tried and I'm not getting succeeded. I have a file called abc.cpp and 2 remote branches say May_Version and June_Version and my file is in the folder /xyz/tools. I tried like

git difftool origin/May_Version:xyz/tools/abc.cpp -- June_Version:xyz/tools/abc.cpp

with the above command it gives the following error

fatal: bad revision 'May_Version:xyz/tools/abc.cpp'

I tried

origin/May_Version:xyz/tools/abc.cpp June_Version:xyz/tools/abc.cpp

fatal: Path 'xyz/tools/abc/cpp' does not exist in May_Version.

Can someone tell me correct syntax?

Richard Telford
  • 9,558
  • 6
  • 38
  • 51
user6771624
  • 55
  • 2
  • 8

2 Answers2

0

You should be able to use the syntax

git difftool {local branch} {remote branch} [*optional* filename]

e.g. :

git difftool June_Version origin/May_Version

or if just diffing the specific file

git difftool June_Version origin/May_Version xyz/tools/abc.cpp
Keif Kraken
  • 9,500
  • 1
  • 10
  • 12
  • I tried git difftool June_Version origin/May_Version xyz/tools/abc.cpp and it says fatal:ambiguous argument xyz/tools/abc.cpp: unknown revision or path not in the working tree. Use -- to separate paths from revisions, like this: – user6771624 Aug 29 '16 at 21:08
  • if I use -- to separate the paths, it does not do any thing. – user6771624 Aug 29 '16 at 21:11
  • It might be an issue with the currently checked out branch. You may want to check If git branch marks a current branch any branch as current with an asterisk. If not, you can try doing a reset on the branch git reset --hard <> from http://stackoverflow.com/questions/15628720/fatal-bad-default-revision-head – Keif Kraken Aug 29 '16 at 22:39
0

Do it locally within your repo. No need for origin/.

git difftool --dir-diff June_Version May_Version
arush436
  • 1,748
  • 20
  • 20