问题
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 afterdifftool
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/ $ patchWith
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