Search code examples
gitbeyondcompare

Beyond Compare Git Directory Diff with working directory


How can we do a git directory comparison with the working directory in BeyondCompare?


Solution

  • If you configure BeyondCompare as your standard diff tool, like:

    git config --global difftool.bc.path "c:/Program Files/Beyond Compare 4/bcomp.exe"
    

    Then you are already able to do a directory diff through the command prompt, which is opened in BeyondCompare. You can use the hashes or branch names

    git difftool --dir-diff eb90e84e2996ac90cd67e91affdd1153d96b0ee3 b4650e6207702c99985dc48ed3c65db2b204fcee
    

    Diff with working directory

    You may have noticed that both sides of compare are in "temp" folder, even if one commit hash is HEAD, that is to prevent accidental changes to files (diff is just for viewing), but if you need the ability to change local files in the working directory, then follow below steps.

    1. Add the --symlinks option and HEAD to command:

      git difftool --dir-diff --symlinks  b4650e6207702c99985dc48ed3c65db2b204fcee head
      

      But before you must enable symlinks (if not already done):

      git config --global core.symlinks true
      git config core.symlinks true
      
    2. Then git is creating symlinks which points to the local files.

    3. To reach, that BeyondCompare does the comparison between the local file behind the symlink and the versioned file from the history, you must configure that BC follows symbolic links

      enter image description here

    Finally, you get this:

    BeyondCompare comparison