On Habré, there have already been many articles on distributed version control systems (
DVCS ), their comparisons, as well as comparisons of GUI clients for them. There were also discussions about plugins for IDE for working with git and mercurial. But
there was almost
no information about the tools for visual comparison and resolution of merge conflicts.

Recently, I “jumped” from mercurial (which I still think is more convenient and logical) to git, because the vast majority of projects that interest me use git and are hosted on github. In this regard, the question arose of revising the arsenal of tools, in particular the question of
choosing a tool for visual comparison and merging (diff and merge). In order to fill the lack of information on the site, I decided to write this mini-review. As they say - in hot pursuit.
Under the cat you will also find examples of Git settings for use with DiffMerge and WinMerge under Windows. I think many will save time.
Title | Features | Platform |
KDiff3 http://kdiff3.sourceforge.net/ ')
[ screenshot ]
| This tool was most likely encountered by both git users and mercurial system users, however, a couple of lines will not hurt.
Pros :
- free of charge;
- supports trilateral merger;
- can compare directories;
- with different encodings works fine;
Cons :
- no add-on does not highlight syntax.
Note: Installs with TortoiseHg.
| Windows, Mac OS X, Linux |
DiffMerge http://www.sourcegear.com/diffmerge/index.html
[ screenshot ]
| Pros :
- free of charge;
- supports trilateral merger;
- can compare directories.
Cons :
- There are problems when working with Cyrillic. I think, over time, correct.
- DiffMerge by default does not support syntax highlighting of programming languages.
| Windows, Mac OS X, Linux |
WinMerge http://www.winmerge.org http://ru.wikipedia.org/wiki/Winmerge
[ screenshot ]
| Pros :
- Open source;
- no problems with encodings;
- syntax highlighting without unnecessary gestures;
- directory comparison.
Cons :
- the merge tool is two-way, which can cause inconvenience in some cases;
- Windows only.
Note : I started using this tool for a very long time (even before I started using mercurial and git) and the fact that the merge tool is two-way in most cases does not cause any inconvenience.
| Windows |
Meld http://meld.sourceforge.net/
[ screenshot ]
| Pros :
- GPL v2;
- two-way and three-way file merging;
- directory comparison;
- syntax highlighting (with GtkSourceView installed).
Cons :
- for installation under Windows, you need to install Python, GTK +, Glib, GtkSourceView, which not everyone will like.
| Windows, Mac OS X, Linux Installation instructions for Windows: https://live.gnome.org/Meld/Windows
|
Diffuse http://diffuse.sourceforge.net/
[ screenshot ]
| Pros :
- GPL;
- support 2-way, 3-way and n-way (arbitrary number of files) merge;
- syntax highlighting;
- works great with UTF-8;
- unlimited undo depth (undo);
- convenient code navigation.
Cons :
- unless, impossibility to compare directories.
Note : when merging with the git mergetool command via Git Bash under Windows, a fourth window opens - an “extra” window. You can remove it by correcting the config c: / Git / libexec / git-core / mergetools / diffuse
| Windows, Mac OS X, Linux Note : when installing under Windows, it already includes all the dependencies (unlike Meld), namely Python and the PyGTK package.
|
TKDiff http://sourceforge.net/projects/tkdiff/
[ screenshot ]
| Pros :
- GPLv2;
- you can add bookmarks for differences;
- with encodings it works fine;
Cons :
- the interface is less convenient and looks very poor (see screenshot) than other products.
- no syntax highlighting;
- can not compare directories.
| Windows, Mac OS X, Linux
|
SmartSynchronize http://www.syntevo.com/smartsynchronize/index.html
[ screenshot ]
| Pros :
- tripartite merger;
- no problems with encodings;
- besides files, can compare directories.
Cons :
- a license is required for commercial use;
- syntax highlighting for programming languages is not provided by default. It is possible that you can do something.
Note : SmartySynctonize is built into SmartGit , a handy GUI tool for working with Git (also free for non-commercial use).
| Windows, Mac OS X, Linux |
BeyondCompare http://www.scootersoftware.com/ http://en.wikipedia.org/wiki/Beyond_Compare
[ screenshot ]
| Pros :
- tripartite merger;
- It can compare files, directories, remote directories, archives, as well as MP3 files, images, etc. But the last items are in principle not necessary functionality.
Cons :
- Shareware;
- No version for Mac.
| Windows linux |
Araxis Merge http://www.araxis.com/merge/
[ screenshot ]
| Pros :
- tripartite merger;
- no problems with encodings;
- highlights syntax;
- besides files, can compare directories and synchronize them;
- works well on comparing large files (gigabytes) and large directories;
- generation of reports on the results of the comparison.
- Ribbon-interface (if it can be called a plus).
Cons :
- Shareware;
- No version for Linux.
Note : in the comments, many praise and advise this tool, despite the high cost.
| Windows, Mac OS X |
In principle, all the listed tools do a good job with their tasks and this review is
not a topic for debate , because Everyone chooses a tool to taste.
The following are examples of Git settings for working with DiffMerge and WinMerge. By analogy, you can configure Git to interact with other tools.
Git and DiffMerge
1) Add to the directory
c: / Git / libexec / git-core / mergetools /The diffmerge file is as follows:
diff_cmd () { "c:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe" \ "$LOCAL" "$REMOTE" >/dev/null 2>&1 } merge_cmd () { "c:/Program Files/SourceGear/Common/DiffMerge/sgdm.exe" \ --merge --result="$MERGED" "$LOCAL" "$BASE" "$REMOTE" >/dev/null 2>&1 status=$? }
2) Now add to the file
c: /Users/swipe/.gitconfigfollowing lines:
[diff] tool = diffmerge [merge] tool = diffmerge [mergetool "diffmerge"] cmd = "diffmerge" trustExitCode = true
3) Create a conflict and call DiffMerge to resolve it
git init

git difftool master new

git merge new

Displays a message about the merge conflict, which we sought.
git mergetool

In the middle window, bring the file to the desired state and save the changes.
Conflict resolved.
DiffMegre peeped here:
http://twobitlabs.com/2011/08/install-diffmerge-git-mac-os-x/Git and winmerge
1) Add to the directory
c: / Git / libexec / git-core / mergetools /The winmerge file is as follows:
diff_cmd () { "c:/Program Files (x86)/WinMerge/WinMergeU.exe" \ "$LOCAL" "$REMOTE" >/dev/null 2>&1 } merge_cmd () { "c:/Program Files (x86)/WinMerge/WinMergeU.exe" \ "$PWD/$LOCAL" "$PWD/$REMOTE" "$PWD/$MERGED" >/dev/null 2>&1 status=$? }
When Git cannot automatically merge changes, a merge conflict occurs and merge markers are added to the conflicting file (<<<<<<<, =======, and >>>>>>>). They are needed to resolve the conflict using third-party tools.
Consider the
readme.txt file that results from the merging of the
master and new branches in the example above:
<<<<<<< HEAD master str ======= new str >>>>>>> new
We can open a conflict file using WinMerge to resolve the conflict.

After this, the two-way merge tool will open:

Based on the described logic, we will rewrite the merge command
merge_cmd as follows:
merge_cmd () { "c:/Program Files (x86)/WinMerge/WinMergeU.exe" \ "$MERGED" >/dev/null 2>&1 status=$? }
In fact, both of the above options are equivalent.
2) Edit
.gitconfig [diff] tool = winmerge [difftool "winmerge"] cmd = "winmerge" [merge] tool = winmerge [mergetool "winmerge"] cmd = "winmerge" trustExitCode = false keepBackup = false
The last line cancels the backup files in the repository directory.
3) Create a conflict when merging two branches (see the example using DiffMerge).
git difftool master new

To resolve the conflict when merging branches, use the command
git mergetool

Edit our file. After saving the changes, the conflict will be resolved.
Settings WinMerge peeped here:
http://stackoverflow.com/questions/636253/msys-git-merge-tool-command-options-issue