When we commit our changes on svn, we may get an error message:
$ svn commit -m "Updated README" Sending README Transmitting file data .svn: Commit failed (details follow): svn: Out of date: '/myproject/README'
It says that the file we want to commit has changed since we last updated it. Update the file to get it up-to-date again.
$ svn update C README Updated to revision 6.
The 'C' indicates there is a conflict with the README file, and Subversion does not know how to solve this.
If we now take a look at README, we'll notice that there are several markers that indicate what parts of the code are conflicting. We can easily see what we changed, and what has changed in the repository:
<<<<<<< .mine This is fun stuff! ======= This is a documentation file >>>>>>> .r6
What are our options?
We have three options for resolving the conflict. Whatever to choose, make sure you confer with your colleague on the matter.
1. Scrap your changes, and go with the current work from your colleague.
This is the easiest solution. All you have to do is revert the changes you made, and update your working copy:
$ svn revert README Reverted 'README' $ svn update README At revision 6.
2. Keep your changes, and dump whatever your colleague did.
Performing a simple 'ls' will show you that there are four files related to this conflict:
- README – the original with markers
- README.mine – your version
- README.r5 – the original your worked with
- README.r6 – the most update version from your colleague
To check in your changes, copy your version over the original and tell Subversion you have resolved the conflict.
$ cp README.mine README $ svn resolved README Resolved conflicted state of 'README'
The 'resolved' command will clean up all the special files that were generated.
3. Merge both version to a new version
If you choose this option, you will have to manually edit README. Remove the markers and add whatever you need to add here.
Subversion won't let you commit this file, so you'll have to mark it as 'resolved' as we saw during option 2:
$ svn resolved README Resolved conflicted state of 'README'
To better understand why does conflicts occur visit http://php-geeks-wink.blogspot.in/2012/07/how-conflict-occurs-in-svn.html
No comments:
Post a Comment