Warning: Cannot merge binary files: HEAD:hello.txt vs. PS> echo Hello World! Hello indeed! > hello.txt : created e71437b: "Update from helloGit branch" PS> git commit -m "Update from helloGit branch" : created 2a2cf34: "Initial commit"ġ files changed, 0 insertions(+), 0 deletions(-) Initialized empty Git repository in C:/Development/Git/HelloWorld/.git/ I’ll open up a PowerShell window and let’s see how we go (you’ll have to excuse me for using old DOS commands instead of fancy PowerShell ones, I’ve only just switched to PS after running into various issues with the cmd.exe command line). Let’s make sure everything’s in working order. I’ve also left in a KDiff3 version that seems to work too (Git has some built in support for KDiff3 I think, which is why you can get away with only specifying the path). The details on the arguments are available from the git-mergetool(1) man page. Now remember that C:\Program Files\Git\cmd is on my PATH, so I can set the command to call git-merge-diffmerge-wrapper.sh without fully qualifying the path.
Path = C:/Program Files/KDiff3/kdiff3.exe gitconfig again: Ĭmd = git-merge-diffmerge-wrapper.sh "$PWD/$LOCAL" "$PWD/$BASE" "$PWD/$REMOTE" "$PWD/$MERGED" I unashamedly stole this from Alexander Groß’s post on getting DiffMerge running on Cygwin-based Git (with slight modifications, any faults are mine :)). # Passing the following parameters to mergetool: This file ended up looking like this: #!/bin/sh Again I ended up using the wrapper approach, creating git-merge-diffmerge-wrapper.sh at C:\Program Files\Git\cmd to call DiffMerge. I had more trouble getting a merge tool working, largely because putting references to paths like C:/Program Files/. We can now use git diff and it will fire up our diff tool of choice. You’ll need to have the following section in there: Įxternal = C:/Program Files/git/cmd/git-diff-wrapper.sh In your home directory ( C:\Users\(username) or the corresponding Documents and Settings equivalent) Git will normally have created a. The next step is telling Git about your wrapper.
I ended up settling on DiffMerge because it is purdy (unlike KDiff3 – sorry), and also does 3-way merges (unlike WinMerge, which was my previous diff tool of choice).
You’ll also see I’ve commented out calls to WinMerge and KDiff3, which are both free as in beer and speech. In this case I’ve used it to setup a call to Sourcefear’s DiffMerge, a nice free (as in beer) diff and merge tool. Provided your diff tool can be called from the command line, you’ll be able to set it up to work with Git using this template. The basic format of this is stolen directly from this post on the Msysgit site. #"C:/Program Files/WinMerge/WinMergeU.exe" "$2" "$5" | cat "C:/Program Files/SourceGear/DiffMerge/DiffMerge.exe" "$2" "$5" | cat # path old-file old-hex old-mode new-file new-hex new-mode # diff is called by git with 7 parameters:
The file contents looks like this: #!/bin/sh To make things easy on me I put the script, git-diff-wrapper.sh in C:\Program Files\Git\cmd, which is in my Path environment variable. The easiest way I found to do this was to create a shell script wrapper for your diff tool of choice. I had to switch to using git difftool instead.
Update : This approach stopped working for me when I upgraded to Windows 7 and Git 1.6.3.