Resolving Conflicts in Subversion
When you’re committing changes to Apache Subversion’s central repository, you may occasionally encounter a conflict which will cause your commit to fail.
You’ll be unable to commit any changes to the repository until you’ve resolved all the conflicts. The good news is that Apache Subversion has all the functionality needed to quickly resolve whatever conflicts you may encounter.
1) Perform an Update
It’s possible that the changes you’ve made and the changes that have already been committed affect different parts of the conflicted file. Therefore, the first step is to perform an svn update:
svn update (path)
Subversion will then try and merge the changes from the server into your working copy, without overriding any of your local changes. If the changes affect different areas of the file, the server will merge the changes and you’ll be able to perform your commit. However, if you’ve modified the same sections of the file (e.g the same lines in a text file), Subversion will be unable to automatically merge the changes and the command line window will present you with several options to resolve the conflict:
(p) postpone – marks the conflict to be resolved later.
(df) diff-full – displays the differences between the HEAD revision and the conflicted file.
(e) edit – opens the conflicted file in an editor (this is set in the EDITOR environment variable)
(mc) mine-conflict – discards changes from the server that conflict with your local changes; all non-conflicting changes are accepted
(tc) theirs-conflict – discards local changes that conflict with changes from the server; all non-conflicting local changes are preserved
- (s) show all options – displays additional options
Enter ‘s’ to be presented with some additional options:
Once you’ve resolved the conflict, perform an ‘svn commit’ to send your changes to the repository.