Search code examples
gitgit-diffbeyondcomparegit-difftool

git difftool directories between branches


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.


Solution

  • 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