Git difftool in Windows to see list of all changed files in addition to file diffs (a la Kaleidoscope)?

落爺英雄遲暮 提交于 2019-12-18 01:10:58

问题


When I do a git difftool, Kaleidoscope shows me all the files that have changed in the left sidebar:


(source: kaleidoscopeapp.com)

Is there any diff-tool in Windows that would show me such a list of files?

(I don't want the tool to open all the files at the same time in separate windows. I'm looking for a single window that will show me the list of files changed, and I should be able to click on a particular file to see its diff, as shown in the Kaleidoscope screenshot)


回答1:


You can use git difftool in a way which lists all the files (git1.8+ recommended):

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

You can then integrate it with a BeyondCompare for instance.

Or with WinMerge:

[diff]
    tool = winmerge
[difftool "winmerge"]
    path = C:/Program Files (x86)/WinMerge/winmergeu.exe
    cmd = \"C:/Program Files (x86)/WinMerge/winmergeu.exe\" -r -u \"$LOCAL\" \"$REMOTE\"

All that with:

    $ git difftool [<commit> [<commit>]]

The only problem is the git diff-tool, on Windows, is described in this blog post, by nitoyon.

On Unix and MacOS, git difftool --dir-diff create a symbolic link to the working directory if a right-hand file has the same SHA1 as the file in the working directory. It's very useful when we modify right-hand files with a difftool.

On Windows, instead of creating symbolic links, git difftool --dir-diff copy back right-hand files to working directory after difftool program exits. I want to use symlinks on Git for Windows like Unix and MacOS.

Note: On Windows, administrator privileges is required to create symbolic links.

Run GitBash as an administrator, and enter following command.

$ git difftool -d --symlinks [<commit> [<commit>]]

If you want, create an alias on .gitconfig.

[alias]
    d = difftool -d --symlinks

But that requires:

  • to create a git mklink command:
C:\Program Files (x86)\Git\libexec\git-core\git-mklink:

#!/bin/sh

cmd.exe /c "mklink \"$2\" \"$1\"" > /dev/null
  • to patch msysgit 1.8.3:
cd /c/Program\ Files\ \(x86\)/Git/libexec/git-core/
$ patch 

With git-difftool.patch:

--- git-difftool Sun Jun 2 11:28:06 2013 +++ git-difftool Tue Jul 9 00:42:02 2013 @@ -283,7 +283,7 @@ exit_cleanup($tmpdir, 1); } if ($symlinks) { - symlink("$workdir/$file", "$rdir/$file") or + !system("git", "mklink", "$workdir/$file", "$rdir/$file") or exit_cleanup($tmpdir, 1); } else { copy("$workdir/$file", "$rdir/$file") or @@ -448,7 +448,7 @@ my $indices_loaded = 0; for my $file (@worktree) { - next if $symlinks && -l "$b/$file"; + next if $symlinks; next if ! -f "$b/$file"; if (!$indices_loaded) {


来源:https://stackoverflow.com/questions/17736427/git-difftool-in-windows-to-see-list-of-all-changed-files-in-addition-to-file-dif

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