A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

Subversion Crash Course

I have been using Subversion for almost a year now but I still only know the basics. Add-update-commit, that’s pretty much about it. But lately, I encountered something while coding pet project called MyLyricsFinder.com – I got conflicts. I had no idea how to resolved this so I fired up my iGoogle and then found this subversion crash course.

If you’ve never used a version control system that makes use of conflict markers, the best way to understand them is through an example. Suppose you have a file in your working copy, hello.c, that looks like this:

#include 
int
main (int argc,char *argv [])
{
   printf ("hello world n");
   return 0;
}

Then say you change the hello world string to Hello World, and before checking in your changes you update your working copy and find that someone else has already changed that line of the file. The copy of hello.c in your working copy will end up looking something like this:

#include 
int
main (int argc, char *argv [])
{
< <<<<<<.mine
   printf ("Hello World n");
=======
   printf ("hello world!n");
>>>>>>>.r5
   return 0;
}

The < <<<<<<, =======, and >>>>>>> lines are used to indicate which of your changes conflicted. In this case, it means that your version of the section of hello.c that you changed looks like printf (“Hello World n”);, but in a newer version of the file that has already been checked into the repository, that line was changed to printf (“hello world!n”);.

Of course, all of this only works if the file in question is in a format that Subversion understands well enough that it can merge the changes automatically. At the moment, that means the file must be textual in nature. Changes to binary files such as image files, sound files, Word documents, and so forth can’t be merged automatically. Any conflicts with such files will have to be handled manually by the user. To assist in that merging, Subversion provides you with copies of the original version of the file you checked out, your modified version, and the new version from the repository, so you can compare them using some other tool.

Click here for the subversion crash course.

This entry was posted in General and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>