DevOps Zone is brought to you in partnership with:

Jessica Thornsby is the Technical and Creative Copywriter at WANdisco, where she writers regular tutorials on Apache Subversion, TortoiseSVN, uberSVN, and all things version control. She spends her spare time editing the CD reviews section at www.leedsmusicscene.net, contributing to A Short Fanzine About Rocking, and researching her family tree. You can find her on Twitter @jthornsby Jessica is a DZone MVB and is not an employee of DZone and has posted 29 posts at DZone. You can read more from them at their website. View Full User Profile

Resolving Conflicts in Subversion

03.24.2013
| 3373 views |
  • submit to reddit

When you’re committing changes to Apache Subversion’s central repository, you may occasionally encounter a conflict which will cause your commit to fail.

resolving conflict

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

resolving conflict 2

Enter ‘s’ to be presented with some additional options:

avoiding conflicts 3

Once you’ve resolved the conflict, perform an ‘svn commit’ to send your changes to the repository.

Published at DZone with permission of Jessica Thornsby, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)