# Doing A Merge

You can either merge the currently selected item (file or directory), or all items. When you have made all your operation choices (in all subdirectories too) then you can start the merge.

Be aware that if you didn't specify a destination directory explicitely, then the destination will be "C" in three directory mode, "B" in two directory merge mode, and in sync-mode it will be "A" or/and "B".

If you have specified a destination directory also check that all items that should be in the output, are in the tree. There are some options that cause certain items to be omitted from the directory comparison and merge. Check these options to avoid unpleasant surprises:

- "Recursive Directories": If this is off, then items in subdirectories will not be found.

- "Pattern"/"Anti-Pattern": Include/exclude items that match

- "Exclude Hidden Files"

- "List only Deltas": Files that match in all directories don't appear in the tree, and hence also not in the destination.

(In the current version, you must do a rescan via menu "Directory"->"Rescan" yourself, after changing options affecting the directory scan.)

If you are satisfied so far, the rest is easy.

To merge all items: Select "Start/Continue directory merge" in the "Directory"-menu or press F7 (which is the shortcut). To merge only the current item: Select "Run Operation For Current Item" or press F6.

If due to conflicting filetypes still some items with invalid operations exist, then a messagebox will appear and these items will be pointed out, so you can select a valid operation for the item.

If you merge all items a dialog will appear giving you the options "Do it", "Simulate it" and "Cancel".

- Select "Simulate it" if you want to see what would be done without actually doing it. A verbose list of all operations will be shown.

- Otherwise select "Do it" to really start merging.

Then KDiff3 will run the specified operation for all items. If manual interaction is required (single file merge), then a merge window will open (see the big screenshot).

When you have finished with a file, again select "Start/Continue directory merge" or the key F7. If you haven't saved yet, a dialog will ask you to do so. Then KDiff3 will continue with the next item.

When KDiff3 encounters an error, it will tell you so and will show the verbose-status-information. At the bottom of this list, there will be some error messages which should help you to understand the cause of the problem. When you continue merging (F7 key) KDiff3 will give you the choice to retry or skip the item that caused the problem. This means that before continuing you can choose another operation or solve the problem by other means.

When the merge is complete, then KDiff3 will inform you via a message box.

If some items were merged individually then KDiff3 remembers this (while this merge-session goes on), and doesn't merge them again when later the merge for all items is run. Even when the merge was skipped or nothing was saved these items count as completed. Only when you change the merge operation the item will be merged again.