简体   繁体   English

分支或提交的Git diff在可视difftool中显示文件列表概述,然后可选择单个文件diff

[英]Git diff of branches or commits showing file list overview in visual difftool and then selectable single file diff

tl;dr: How can I get my custom difftool to open a directory/file view of a branch or commit diff so I can jump inside of my difftool in single file diffs and back to directory list to select the next pair of files? tl;博士:如何获取自定义的difftool来打开分支的目录/文件视图或提交diff,以便可以跳入difftool的单个文件diff中并返回目录列表以选择下一个文件对? Using git and Beyond Compare 4. (Jumping back and forth from file list to file diff and back is partly a build in feature of the difftools). 使用git和Beyond Compare4。(从文件列表到文件diff来回跳转是difftools功能的一部分)。

Details: 细节:
I have been working myself into Git the last couple of month and it is a great tool. 在过去的几个月中,我一直在致力于Git,这是一个很好的工具。 But I was wondering if there is a possibility to solve a feature I haven't found during my internet searches on git topics. 但是我想知道是否有可能解决我在git主题上进行互联网搜索时未找到的功能。 Scripting something to get a similar behavior would also be fine. 编写脚本以获得类似的行为也可以。 But maybe it is build-in or someone solved the problem already? 但是也许是内置的,还是有人已经解决了问题?

What am I trying to do? 我想做什么?
From my former work environment I had the possibility to select to see a diff of 2 checkins (commits). 从我以前的工作环境中,我可以选择查看2个签到(提交)的差异。 It opened a file/directory diff list in my custom diff tool and I saw all files side by side. 它在我的自定义差异工具中打开了一个文件/目录差异列表,我并排看到了所有文件。 On one side commit (or branch) No. one an on the other side commit (or branch) No. two. 在一侧提交(或分支)第一个,在另一侧提交(或分支)第二。 I could select a file pair and see a diff of the 2 files and jump back into the directory/file list (custom difftool feature) when finished. 我可以选择一个文件对,查看两个文件的差异,并在完成后跳回到目录/文件列表(自定义difftool功能)。

What is my git doing? 我的git在做什么?
Currently if I do a diff involving several files like 目前,如果我做一个涉及多个文件的比较

git difftool branch1..branch2

the git bash opens one file after the other. git bash打开另一个文件。 Asking for each one separately. 分别要求每个人。 This is a bit ackward if there are many files and in case I am not sure what I want to look at beforehand or if I just want to get an overview. 如果有很多文件,并且如果我不确定我想先看一下还是只想获得概述,这有点麻烦。 And I would especially prefer to see it in my difftool. 我尤其希望在我的difftool中看到它。

Ann.: A more sofisticated feature would be to be able to see a 3 file diff including the common ancestor of the file (but not in the file/directory view). Ann .:更复杂的功能是能够看到3个文件的差异,包括文件的共同祖先(但不在文件/目录视图中)。

Infos: 相关信息:
I am on a windows platform so if you know of a linux solution or have one set up please give me some info on involved linux internals. 我在Windows平台上,因此,如果您了解linux解决方案或进行了设置,请给我一些有关所涉及的Linux内部信息。
Possibly the tools I am using have a "secret" feature already? 我使用的工具可能已经具有“秘密”功能了吗? They are Visual Studio 2013 and Sourcetree additionally to command line git bash. 除了命令行git bash之外,它们是Visual Studio 2013和Sourcetree。
if relevant: The difftools I am using are Beyond Compare 4 and Sourcegear DiffMerge. 如果相关:我使用的difftools是超越Compare 4和Sourcegear DiffMerge。

I don't know what I was looking at all the time. 我不知道我一直在看什么。 I just stumbled upon the solution when I did some diffs and reread the help page for git diff-tool to remember a parameter. 当我做一些比较时,我偶然发现了该解决方案,然后重新读取了git diff-tool的帮助页面以记住一个参数。 Usually I only read git diff help page because they share the same parameters. 通常我只阅读git diff帮助页面,因为它们共享相同的参数。

There I saw the parameter -d and gave it a try. 在那里,我看到了参数-d并尝试了一下。
The solution for a 2-way diff with folders and files is the command: 具有文件夹和文件的2向差异的解决方案是以下命令:

git difftool -d branch1 branch2
git difftool --dir-diff branch1 branch2

or 要么

git difftool -d commit1 commit2

then Beyond Compare opens in directory diff mode and I can see the differences between the branches or commit. 然后以目录差异模式打开“超越比较”,我可以看到分支或提交之间的差异。
Although you can only see the changed files not including the unchanged. 虽然您只能看到更改的文件,但不包括未更改的文件。 But it is not really a drawback. 但这并不是真正的缺点。

In the help file at git-difftool it says: git-difftool的帮助文件中说:

-d
--dir-diff

    Copy the modified files to a temporary location and perform a       
 directory diff on them. This mode never prompts before launching the diff tool.

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM