Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Update June 2015, 6 years later:</p> <p>As detailed in "<a href="https://stackoverflow.com/a/30699239/6309">git mergetool winmerge</a>", a simple <code>git config diff.tool winmerge</code> will be enough.</p> <p>Git 2.5+ (Q2, 2015) is now aware of Winmerge as a diff or merge tool!</p> <hr> <p>Original answer (2009-2012)</p> <p>(msysgit, 1.6.5, DOS session)</p> <p>The first part (using winmerge) is described in "<a href="https://stackoverflow.com/questions/255202/how-do-i-view-git-diff-output-with-visual-diff-program/949242#949242">How do I view ‘git diff’ output with visual diff program?</a>"</p> <pre><code>C:\myGitRepo&gt;git config --replace --global diff.tool winmerge C:\myGitRepo&gt;git config --replace --global difftool.winmerge.cmd "winmerge.sh \"$LOCAL\" \"$REMOTE\"" C:\myGitRepo&gt;git config --replace --global difftool.prompt false </code></pre> <p>With <code>winmerge.sh</code> stored in a directory part of your <code>PATH</code>:</p> <pre><code>#!/bin/sh echo Launching WinMergeU.exe: $1 $2 "$PROGRAMFILES/WinMerge/WinMergeU.exe" -e -u -dl "Local" -dr "Remote" "$1" "$2" </code></pre> <p>(see <a href="http://winmerge.org/docs/manual/CommandLine.html" rel="noreferrer">WinMerge Command-line options</a>) </p> <pre><code>git difftool </code></pre> <p>will now launch WinMerge.<br> If you want <code>git diff</code> to launch WinMerge, just set:</p> <pre><code>set GIT_EXTERNAL_DIFF=winmerge.sh </code></pre> <hr> <p>But the real added value comes from the ability to use that same diff tool to <strong>present all differences in one batch</strong> instead of presenting them sequentially, forcing you to close the diff tool windows one file at a time.</p> <p><strong>Update June 2012</strong> (2-and-a-half years later):</p> <p>Comparing directories instead of file-by-file will be available soon:<br> See <a href="http://article.gmane.org/gmane.linux.kernel/1307164" rel="noreferrer">[ANNOUNCE] Git 1.7.11.rc1</a>:</p> <blockquote> <p>"<code>git difftool</code>" learned the "<code>--dir-diff</code>" option to spawn external diff tools that can <strong>compare two directory hierarchies</strong> at a time after populating two temporary directories, <strong>instead of running an instance of the external tool once per a file pair</strong>.</p> </blockquote> <p>See "<strong><a href="http://winmerge.org/docs/manual/CommandLine.html" rel="noreferrer">Patch <code>difftool</code>: teach <code>difftool</code> to handle directory diffs</a></strong>", and the answer "<a href="https://stackoverflow.com/a/10879804/6309">Directory comparison of Git branches</a>" for more details.</p> <hr> <p>Original difftool by directories script (December 2009)</p> <p>As <a href="https://stackoverflow.com/users/93451/seba-illingworth">Seba Illingworth</a> mentions in <a href="https://stackoverflow.com/questions/255202/how-do-i-view-git-diff-output-with-visual-diff-program/1339962#1339962">his answer</a>, a script git-diffall.sh (also put in the path) can do just that:</p> <pre><code>#!/bin/sh git diff --name-only "$@" | while read filename; do git difftool "$@" --no-prompt "$filename" &amp; done </code></pre> <p>But that only works by opening <em>n</em> windows for <em>n</em> files (if you try to use the <code>-s</code> option of WinMerge, it will not work because of the temp files being deleted by the difftool too early)</p> <hr> <p>That is why I like the approach of <a href="http://blogs.msdn.com/shrib/archive/2009/04/13/gitdiff-bat-power-diffing-with-git.aspx" rel="noreferrer">GitDiff.bat - power-diffing with GI</a>, which allows you to review the list of files with a difference, before selecting one to examine its internal differences.<br> I have tweaked it to use only DOS commands</p> <pre><code>@echo off setlocal if "%1" == "-?" ( echo GitDiff - enables diffing of file lists, instead of having to serially echo diff files without being able to go back to a previous file. echo Command-line options are passed through to git diff. echo If GIT_FOLDER_DIFF is set, it is used to diff the file lists. Default is windff. goto END ) if "%GIT_DIFF_COPY_FILES%"=="" ( rd /s /q %TEMP%\GitDiff mkdir %TEMP%\GitDiff mkdir %TEMP%\GitDiff\old mkdir %TEMP%\GitDiff\new REM This batch file will be called by git diff. This env var indicates whether it is REM being called directly, or inside git diff set GIT_DIFF_COPY_FILES=1 set GIT_DIFF_OLD_FILES=%TEMP%\GitDiff\old set GIT_DIFF_NEW_FILES=%TEMP%\GitDiff\new set GIT_EXTERNAL_DIFF=%~dp0\GitDiff.bat echo Please wait and press q when you see "(END)" printed in reverse color... call git diff %* if defined GIT_FOLDER_DIFF ( REM This command using GIT_FOLDER_DIFF just does not work for some reason. %GIT_FOLDER_DIFF% %TEMP%\GitDiff\old %TEMP%\GitDiff\new goto END ) if exist "%ProgramFiles%\Beyond Compare 2\BC2.exe" ( set GIT_FOLDER_DIFF="%ProgramFiles%\Beyond Compare 2\BC2.exe" "%ProgramFiles%\Beyond Compare 2\BC2.exe" %TEMP%\GitDiff\old %TEMP%\GitDiff\new goto END ) "%ProgramFiles(x86)%\WinMerge\WinMergeU.exe" -r -e -dl "Local" -dr "Remote" %TEMP%\GitDiff\old %TEMP%\GitDiff\new goto END ) REM diff is called by git with 7 parameters: REM path old-file old-hex old-mode new-file new-hex new-mode copy %TEMP%\%~nx2 %GIT_DIFF_OLD_FILES%\%1 copy %5 %GIT_DIFF_NEW_FILES% :END </code></pre> <p>It is not robust enough to handle files with same names in different directories, but it gives you a general idea of what is possible:<br> Here only one WinMerge will open up, with the list of files having internal differences. You can click on the ones you want to examines, then a simple <kbd>ESC</kbd> will close the all <code>WinMerge-diff</code> session.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload