avoiding SVN conflicts using svn:ignore

I ran into this issue today: Dealing with conflictive files/directories in projects using Subversion. For example: Log directories and configuration files. But I’ve seen this problem before in my projects. I really like working in teams. But I also like having my own work environment.

I don’t really like sharing the database I use for development with other people. I guess it’s because of my experience and many past headaches due to teammates introducing conflicting changes (the system starts failing, ‘magically’)

This is a good practice suggested by Subversion: Use .tmpl files for conflictive resources in your projects. In my Rails projects, the conflictive file is usually database.yml -

My teams like to work with a development database in the Aycron office. I like to work with a local database. I believe it’s faster and safer. I save time by using my local MySQL database.

Here is what you should do, in order not to share the same database.yml:

1. Create your Rails project structure

[etagwerker@benteveo trunk]$ rails test-local -d mysql

2. Rename database.yml to database.yml.tmpl

[etagwerker@benteveo test-local]$ cd test-local

[etagwerker@benteveo test-local]$ mv config/database.yml config/database.yml.tmpl

3. Commit all your code to the SVN repository

4. Create your local copy from your template

[etagwerker@benteveo test-local]$ cp config/database.yml.tmpl config/database.yml

5. Ignore database.yml for the rest of your project

[etagwerker@benteveo test-local]$ cd config

[etagwerker@benteveo config]$ svn propset svn:ignore database.yml .

6. Commit the config directory

[etagwerker@benteveo config]$ svn ci

You’re done! Your teammates can do whatever they want with the database.yml, you can do whatever you want and there will be no conflicts over that file. Because it will never get committed to the SVN repository.

This entry was posted in IT services business, developer tools, web programming and tagged , , , , . Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

2 Comments

  1. vijai
    Posted June 10, 2009 at 4:53 pm | Permalink

    Have u looked at distributed repositories? for instance, git
    http://git-scm.com/

  2. admin
    Posted June 14, 2009 at 2:12 pm | Permalink

    I have used GIT only once. It’s probably the evolution of source repositories. But I don’t think it has that many advantages over SVN.

Post a Comment

Your email is never published nor shared. 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>