Reputation: 1082
Often when I do diffs I want to edit my local file before committing. This works very well in Eclipse's compare view as it allows you to easily edit the local file as well as copy changes from the previous version.
I am trying to set up Git and KDiff3 to work the same way. It works as expected when I'm using KDiff3 as my mergetool. However when I set it up as the difftool, it gives me a read-only view, so I can't do any edits. According to the documentation (http://kdiff3.sourceforge.net/doc/documentation.html), I would expect the --output
option to give me the two file merge I want, but it does not. The relevant part of my .gitconfig:
[diff]
tool = kdiff3
[difftool "kdiff3"]
cmd = /Applications/kdiff3.app/Contents/MacOS/kdiff3 $LOCAL $REMOTE --output $LOCAL
trustExitCode = false
Upvotes: 15
Views: 8447
Reputation: 3897
Here a step by step guide to configure kdiff3 for GIT in Eclipse:
can be skipped if there is already a .gitconfig file in your userdir.
Windows users:
%userprofile% (copy paste in Explorer adress bar)
a file named ".gitconfig" needs to exist there
1.1 open a cmd window, execute:
git config --global --edit
Open the config file ".gitconfig" 2.1 add the following lines to register kdiff3 as the diff and merge tool for git (customize the paths to you needs):
[difftool "kdiff3"]
path = "C:\Program Files\KDiff3/kdiff3.exe"
#
[mergetool "kdiff3"]
path = "C:\Program Files\KDiff3/kdiff3.exe"
#trustExitCode = true
#
Note: This would be the location to register any other supprted mergetool of your liking.
Location:
C:\Program Files\Git\bin\git.exe
Working directory:
${git_work_tree}
Arguments:
mergetool --tool=kdiff3
To execute a merge, use the standard eclipse merge and as soon as the workspace shows the conflicted state (red markers on projects visible) you mark a project you wish to merge and start the "external tools configuration" we created in the steps listed above.
The merge will start and the kdiff3 window will pop up. from now just go along your business and only save the files when you are happy with the merge result, as kdiff will deliver a positive merge feedback if you have saved the file.
Upvotes: 0
Reputation: 822
I can use KDiff3 to edit the in-tree file if I use the following command:
kdiff3 $LOCAL $REMOTE --output $MERGED
KDiff3 is in my $PATH
, so the important bit is to change the output from $LOCAL
to instead be $MERGED
.
From the git-difftool
manpage:
...the configured command line will be invoked with the following variables available: $LOCAL is set to the name of the temporary file containing the contents of the diff pre-image and $REMOTE is set to the name of the temporary file containing the contents of the diff post-image. $MERGED is the name of the file which is being compared.
Since setting the output to $LOCAL
is going to write to a temporary file, you'll instead want to write to $MERGED
since that will be the actual "local" in-tree file.
Upvotes: 8