【问题标题】:Is it possible to compare two directories in Git [duplicate]是否可以在 Git 中比较两个目录 [重复]
【发布时间】:2017-07-21 07:50:42
【问题描述】:

我已经在 Git 中安装了 Meld 作为 diff 工具。是否可以使用 Git 或任何其他方式比较两个文件夹?我尝试了以下命令,但没有任何反应。

git diff /c/sample/folder1/ /c/sample/folder2/

【问题讨论】:

  • 怎么“什么都没发生”?预计会起作用。
  • 只有当两个文件夹都是 git 项目时才有效。

标签: git diff meld


【解决方案1】:

如果你想比较磁盘上的两个目录,不需要git

# use any suitable diff viewer : meld, kdiff3 ...
meld /c/sample/folder1/ /c/sample/folder2/

如果你想在 git 中获得两个提交之间的差异的目录视图:

git difftool -d <commit1> <commit2>

# you can also restrict this directory view to a subdir of your repo :
git difftool -d <commit1> <commit2> -- lib/

【讨论】:

    【解决方案2】:

    使用git diff master..yourbranch path/to/folder 比较git 存储库中不同版本 文件夹实际上是完全正常的(请参阅this 问题)。

    如果不是关于版本,而只是比较两个文件夹,meld 可以做到:

    Meld 可让您并排比较两个或三个文件夹。你可以开始了 通过选择 File ▸ New... 菜单项进行新文件夹比较,以及 点击目录比较选项卡。

    (来自here)。

    【讨论】:

    • 另外,如果你想使用 Git 来比较两个任意文件夹,你可以使用 --no-index 选项:git diff --no-index dir1 dir2
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-19
    • 2020-01-18
    • 2023-04-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多