0

This question contains two separated but closely related questions:

First; I am attempting to compare two files which are located in different branches (THIS_BRANCH, OTHER_BRANCH)

The file (file.txt) path has been moved around between the branches. THIS_PATH\file.txt and OTHER_PATH\file.txt (where THIS_PATH!=OTHER_PATH)

Executing git difftool THIS_BRANCH OTHER_BRANCH -- THIS_PATH\file.txt this (expectedly) yields comparing the file to a file that does not exist, essentially compares it to nothing.

How can I do that using git difftool? [I am using beyond compare (already configured to be my git difftool)]

Second; Similarly, i'd like to compare two directories from two different branches (THIS_DIR, OTHER_DIR) which have different paths leading to them (THIS_PATH, OTHER_PATH). Again, using beyond compare as my difftool. how can this may be accomplished?

Appreciate it.

orialz
  • 75
  • 1
  • 9

1 Answers1

1

You can run git difftool [options] <blob> <blob>

where <blob> can be <rev>:<path>, and <path> should be relative to the repo root directory.

E.g.

git difftool @:some/dir @^:some/other_dir
tuntap
  • 401
  • 2
  • 6
  • Thanks! I see how I can use that for comparing two specific files (answering the first question). But when I try to compare two folders it simply iterates for each file under the first branch. Specifically for beyond compare, there is a convenient tool to compare between directories. Is there a way to get git difftool to load the entire directories (at once) to BC? Thank you for you answer! – orialz Jan 11 '18 at 09:28
  • 1
    Perhaps you can try the `-d` option to `git difftool`. I don't know of any other solution. – tuntap Jan 11 '18 at 12:54
  • 1
    When you use `git difftool -d` or `git difftool --dir-diff`, git creates symlinks to the working tree on macOS or Linux (Windows default is no symlinks). BC's default behavior doesn't align files with symlinks, to force them to align, click the **Rules** toolbar button, go to the **Handling** tab, then check **Follow symbolic links**. – Chris Kennedy Jan 16 '18 at 16:02