Beyond 比较 Git 目录与工作目录的差异

Hei*_*eck 1 git beyondcompare

我们如何在 BeyondCompare 中将 git 目录与工作目录进行比较?

Hei*_*eck 6

如果您将 BeyondCompare 配置为标准 diff 工具,例如:

git config --global difftool.bc.path "c:/Program Files/Beyond Compare 4/bcomp.exe"
Run Code Online (Sandbox Code Playgroud)

然后您就可以通过在 BeyondCompare 中打开的命令提示符进行目录比较。您可以使用哈希值或分支名称

git difftool --dir-diff eb90e84e2996ac90cd67e91affdd1153d96b0ee3 b4650e6207702c99985dc48ed3c65db2b204fcee
Run Code Online (Sandbox Code Playgroud)

与工作目录的差异

您可能已经注意到,比较的两边都在“temp”文件夹中,即使一个提交哈希是HEAD,这是为了防止意外更改文件(diff 仅用于查看),但如果您需要能够更改本地文件工作目录,然后按照以下步骤操作。

  1. 添加--symlinks选项和HEAD命令:

    git difftool --dir-diff --symlinks  b4650e6207702c99985dc48ed3c65db2b204fcee head
    
    Run Code Online (Sandbox Code Playgroud)

    但在此之前,您必须启用符号链接(如果尚未启用):

    git config --global core.symlinks true
    git config core.symlinks true
    
    Run Code Online (Sandbox Code Playgroud)
  2. 然后 git 创建指向本地文件的符号链接。

  3. 为了实现 BeyondCompare 对符号链接后面的本地文件和历史记录中的版本化文件进行比较,您必须配置 BC 遵循符号链接

    在此输入图像描述

最后,你得到这个:

BeyondCompare比较