I've been following the directions in the "blog entry by Dave" link in this answer as I'm on Windows 7 and do use SourceGear's DiffMerge tool. I've added the git\cmd
directory to my PATH system variable and put my git-diff-diffmerge-wrapper.sh
file in there:
#!/bin/sh
"C:\Program Files\SourceGear\Common\DiffMerge\sgdm.exe" "$1" "$2" | cat
(Yes, it's the correct path for DiffMerge.)
I've edited my .gitconfig
file to include the diff
and difftool
chunks (I copied the lines directly from the post, and he does leave in the commented-out #external
line. I added this to the end of my file; is that OK? )
[diff]
# external = git-diff-wrapper.sh
tool = diffmerge
[difftool "diffmerge"]
cmd = git-diff-diffmerge-wrapper.sh "$LOCAL" "$REMOTE"
So I go to git bash
and do git difftool HEAD~ 67b8679 -- js/site/pizzabuilder.js
and hit enter. Nothing happens. If I do git difftool HEAD~ 67b8679
, leaving off the file I want, I get this:
Viewing: 'js/angular/hutlovers/hutlovers.js'
Launch 'diffmerge' [Y/n]: Y
C:\Program Files (x86)\Git/libexec/git-core/mergetools/defaults: line 17: git-diff-diffmerge-wrapper.sh: command not found
Viewing: 'js/angular/localization/StoreListCtrl.js'
Launch 'diffmerge' [Y/n]: n
Viewing: 'js/pizzahut/site/browser_version.js'
Launch 'diffmerge' [Y/n]: n
Viewing: 'js/pizzahut/site/dashboard.js'
Launch 'diffmerge' [Y/n]: n
It continues for all of the files that are different between the commits, but it never launches DiffMerge. I don't know how to interpret the error; what command is not found? difftool
? I'm running 1.7.11 in git, and difftool
is supposedly included with git starting with version 1.6.3.
When I look at line 17 of the file referenced in the error, this is what's there:
( eval $merge_tool_cmd )
as part of this block:
diff_cmd () {
merge_tool_cmd="$(get_merge_tool_cmd "$1")"
if test -z "$merge_tool_cmd"
then
status=1
break
fi
( eval $merge_tool_cmd )
status=$?
return $status
}
Can anyone help me out? I'm a daily user of git
, but hardly a power user, and I know nothing about Windows shell scripts, so following the directions in that post is pretty much the limits of my knowledge at this point.
Instead of running one of the known diff tools, git difftool can be customized to run an alternative program by specifying the command line to invoke in a configuration variable difftool. <tool>. cmd . When git difftool is invoked with this tool (either through the -t or --tool option or the diff.
git mergetool allows you to use a GUI merge program (i.e. Meld) to resolve the merge conflicts that have occurred during a merge. Like difftool you can set the GUI program on the command line using -t <tool> / --tool=<tool> but, as before, it makes more sense to configure it in your . gitconfig file.
I know this is an old question and I recognize that my situation may just be me being dumb, but I did spin my wheels trying to figure this out. Hopefully though, someone who made the same mistake as me won't be completely lost in future.
Make sure items show with git diff
!
I had a very simple one line change. Did a git add .
and then got interrupted. Came back to finish up and decided to double check the diffs. I did not realize that doing a git add
would stop me from being able to use git difftool
.
Doing a git reset
allowed git difftool
to work.
None of the other answers worked for me. I finally got diffmerge to work on Windows 7,8,10 using Git 2.6.3, 2.7.0
1) Make sure you can write to and use your global .gitconfig stored at ~/.gitconfig, which is relative to your HOME path.
Use:
git config --global --edit
or just navigate to the file in a windows explorer and edit it that way.
The HOME variable can be set by navigating to environment variables within windows (for 7, right click on Computer-->Properties-->Advanced system settings-->Environment Variables).
2) Make sure diffmerge is in your PATH variable on your machine. This is in the same place as the HOME variable. I added this to my PATH:
C:\Program Files\SourceGear\Common\DiffMerge;
3) To make diffmerge the default add the following to your global .gitconfig file:
[merge]
tool = diffmerge
[mergetool]
prompt = true
[mergetool "diffmerge"]
path = C:\\Program Files\\SourceGear\\Common\\DiffMerge\\sgdm.exe
'\' is an escape character
repeat for difftool stuff and that's all I needed to make it work. No wrapper script or local remote variables were needed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With