KDiff3 is an open source file comparison and merge tool
KDiff3 is an open source file comparison and merge tool that's available for Windows and Linux. It's a KDE project.
Unlike some comparison tools, KDiff3 is capable of three-way comparisons, i.e., you may use it to select up to 3 files or folders for comparison or merging.
Run the program and you'll see a pop-up window overlapping the interface. Select the files or folders to be processed. Let's try it with a couple of documents. The application loads one document in each pane. The differences in the content are highlighted on a color-coded basis.
The interface of KDiff3 is made up of a menu bar and a toolbar. The File and Edit menu are for performing basic operations like opening, saving, copy, paste, cut, etc. The address bar at the top of each pane shows the name and the full path of the loaded file. There is a status bar below it that displays the current line number, the encoding format and line end style of the document.
Use the Diffview menu for additional options such as Word Wrap, Diff Windows, add or clear manual alignment, toggle the line numbers, space and tabulator characters, whitespace. Jump to the next conflict, i.e., difference in the content, by using the movement menu.
When the documents contain whitespace at the same lines, a conflict occurs, and you'll have to use the Merge menu to decide which content should be saved in the output document. And since this is a new file, it does not affect the ones which are being merged. You can also right-click on a conflict to view a context menu that allows you to choose which line to use, the one from Document A or B.
This is a fantastic way to observe the changes made between two or three revisions of a document, without manually having to go over it.
Folder Comparison and Operations
KDiff3 can also be used to compare folders and if required, merge them. Comparing 2 folders displays a summary that tells you the total number of files in the directories, how many of those are the same, and the number of different files. Click ok to view the actions that you can choose. Once again it is presented in a color-coded form, and you can see which files exist in Folder A, the ones in Folder B, and the common ones.
The Folder Menu is activated when you select two directories for comparison. This allows you to merge the folders or specific files. You can also compare selected files. The results can be toggled to show identical files, different files, only those in A or B.
For quick operations, you can use the menu item that lets you select all files in a folder. Once you have selected some files for merging or synchronization. Select the Current Item Merge or Current Sync Operation and pick the folder to be used as the source. You can optionally select the "Delete (if exists)" or Do Nothing option to delete or retain the files in the destination folder.
When you're ready, hit F7 or the Start/Continue Folder Merge option to apply the changes. You'll be given an option to simulate the result, which displays a log of the changes that will take place if you actually proceed with the operation. In this example, IÂ have opted to select folder A as the source. So the contents will be copied to folder B.
KDiff3's Options screen can be accessed from the settings menu. It lets you customize the font type, size, colors used for the difference indicators. There are some advanced options that you can define for the merge, folder settings.
Installers for the Windows version of KDiff3 are available at the Binary Factory page. The program is is also available for Linux from the KDE website. There is an older version on SourceForge that is missing some features.
If this isn't your cup of tea, Meld is a good alternative, that's also open source and cross platform.