Working on a large project with others can be difficult to coordinate. When each user is working on a set of files for some task, sooner or later users will try to commit the same file in two different versions. This is called a conflict.
This guide will demonstrate the basic steps you can take to resolve a conflict once it has happened. We deal with three solution strategies:
- Theirs - choosing to accept all incoming changes and discarding all your own changes to a conflicting file.
- Mine - the opposite of theirs, discarding all changes done by other users to a file since you last updated it from the server.
- Manual/merge - the most time consuming, but by far also most effective strategy. You must manually go through the different versions of conflicting files and assemble a new file from the changes to commit. This is easier than it sounds, although it does require some work.
If conflicts arise, SvnX will silently create three files in the same folder as the conflicting file. In the example, the file main.cpp has been changed locally, and an update was attempted before committing the changed file. However, someone else has already modified the file, causing the conflict.
- main.cpp.mine is the local file with uncommitted changes.
- main.cpp.r14 is the new version with conflicting changes.
- main.cpp.r15 is the original version before the conflicting version.
- main.cpp is now a file with attempted automatic merges and annotations from Subversion.
Thus, after an update with conflicts, folder may look something like what is depicted below. The log output will summarise the conflicts, giving you an impression of how many files will need attention.
To start resolving a conflicted file, click it and click the Resolve button in the toolbar.
This will open a merge application. The window is split into three parts. From the left, it is your version of the file, a number signifying the conflict number, and the new, external version.
Bring a conflict into focus by clicking its number in the middle area and picking a merge option from the list of actions in the bottom-right corner of the window. Your options are as follows:
- Choose left: a mine merge. Choosing to use your version in the consolidated file.
- Choose right: a theirs merge, choosing the new external version.
- Choose both (left first): will insert your version and then the external version into the consolidated file.
- Choose both (right first): like the previous point, only in opposite order.
- Choose neither: no version will be carried over to the new merged version, meaning they are effectively deleted.
Once you have completed the merge actions, close the window, saving your changes.
Back in the main window, select the conflicted file and click Resolved. Confirm your choice by clicking OK.
We recommend you commit your changes right after resolving a set of conflicts, ensuring you get the unified file versions out to all collaborators immediately.