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

穿精又带淫゛_ 提交于 2019-12-14 02:55:39

问题


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? 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).

Details:
I have been working myself into Git the last couple of month and it is a great tool. But I was wondering if there is a possibility to solve a feature I haven't found during my internet searches on git topics. 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). 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.

What is my git doing?
Currently if I do a diff involving several files like

git difftool branch1..branch2

the git bash opens one file after the other. 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.

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).

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.
Possibly the tools I am using have a "secret" feature already? They are Visual Studio 2013 and Sourcetree additionally to command line git bash.
if relevant: The difftools I am using are Beyond Compare 4 and Sourcegear DiffMerge.


回答1:


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. Usually I only read git diff help page because they share the same parameters.

There I saw the parameter -d and gave it a try.
The solution for a 2-way diff with folders and files is the command:

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:

-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.


来源:https://stackoverflow.com/questions/29841994/git-diff-of-branches-or-commits-showing-file-list-overview-in-visual-difftool-an

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!