git difftool 给目录比较?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2113889/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 04:02:57  来源:igfitidea点击:

git difftool to give directory compare?

gitdiffbeyondcompare

提问by Ian Vaughan

Is it possible to get the git difftool command to open a directory compare between the changed files and the staging/checked files?

是否可以使用 git difftool 命令打开目录比较已更改的文件和暂存/已检查的文件?

So ideally, if 2 files have changed, they would be the only 2 shown, but within a directory compare.

所以理想情况下,如果 2 个文件发生了变化,它们将是唯一显示的 2 个,但在目录中进行比较。

I've read posts about getting git to give all file diffs in parallel, so tools like BeyondCompare has all the diffs in tabs, but im not happy with that!

我读过关于让 git 并行给出所有文件差异的帖子,所以像 BeyondCompare 这样的工具在 tabs 中有所有差异,但我对此并不满意!

One could pull a copy of the changed files from staging/checked in files into a temp folder, and then open that up. Is that the only option?

可以将已更改文件的副本从暂存/签入文件中提取到临时文件夹中,然后将其打开。这是唯一的选择吗?

回答by VonC

Update June 2012 (2 and an half years later):

2012 年 6 月更新(两年半后):

This (comparing directories instead of file-by-file) seems to be soon available:
See [ANNOUNCE] Git 1.7.11.rc1:

这(比较目录而不是逐个文件的比较)似乎很快可用:
参见[ANNOUNCE] Git 1.7.11.rc1

"git difftool" learned the "--dir-diff" option to spawn external diff tools that can compare two directory hierarchiesat a time after populating two temporary directories, instead of running an instance of the external tool once per a file pair.

" git difftool"学习了" --dir-diff" 选项来生成外部差异工具,该工具可以在填充两个临时目录后一次比较两个目录层次结构而不是为每个文件对运行一次外部工具实例

See "Patch difftool: teach difftoolto handle directory diffs"

请参阅“补丁difftool:教difftool处理目录差异



Original answer (January 2010)

原始答案(2010 年 1 月)

One could pull a copy of the changed files from staging/checked in files into a temp folder, and then open that up. Is that the only option?

可以将已更改文件的副本从暂存/签入文件中提取到临时文件夹中,然后将其打开。这是唯一的选择吗?

Basically yes:

基本上是的:

You difftool script would:

您的 difftool 脚本将:

  • create 2 temp directories
  • defines itself as a diff tool
  • call git diff
    • which then call itself for file to diff
    • in that mode, the same script, for each files, only copy the two version to diff in the two temp directories
  • then go on and call diff tools (like beyondCompare or WinMerge) on the two temp directories
  • 创建 2 个临时目录
  • 将自己定义为差异工具
  • 调用 git diff
    • 然后调用自己的文件来区分
    • 在这种模式下,相同的脚本,对于每个文件,只将两个版本复制到两个临时目录中的 diff
  • 然后继续在两个临时目录上调用差异工具(如 BeyondCompare 或 WinMerge)

You have one first example in this question.

你在这个问题中有一个第一个例子。

回答by Rudie

I always use --dirstat=files:

我总是使用--dirstat=files

rudie@devver:virenze$ git diff --dirstat=files
   4.1% modules/custom/virenze_conversations/
   7.0% modules/custom/virenze_crs/
   8.3% modules/custom/

which means I've removed dirs virenze_conversationsand virenze_crsin custom. (I don't know what the percentages mean...)

这意味着我已删除了迪尔斯virenze_conversationsvirenze_crscustom。(我不知道百分比是什么意思......)

You can probably use all the normal diffoptions: --cached, branch name etc.

您可能可以使用所有常规diff选项:--cached、分支名称等。