Saturday, May 23, 2009

How to exclude CakePHP's tmp directory on SVN using svn:ignore

I wrote a post before about moving CakePHP's tmp directory outside of app so it won't be included in SVN. It's a good concept but since it's a bit dirty and not standard, it might lead to some problems later and when upgrading.

A better solution to this problem is to just exclude the contents of tmp (or any other directory you don't want to include in SVN). Here's how to do it on TortoiseSVN:
1. Backup the contents of tmp/ (cache, logs, sessions, tests, etc)
2. Delete all the contents tmp/
3. Commit the empty directory tmp/ to svn
4. After commit, right click the tmp/ folder and choose TortoiseSVN-> Properties
5. On the properties dialog, click New.., then set the Property name to svn:ignore and Property value to *
6. Commit the changes to SVN
7. Move back the previous contents of tmp/

There you go! SVN will now ignore the contents of tmp/
Note: when you checkout on another machine, you will have to manually create the folders inside tmp since it's not included in your repository

3 comments:

  1. Nice, how about a linux command line solution?

    ReplyDelete
  2. the idea is good. i just tweaked it.

    1) go in and delete every single file inside all the subfolders of tmp folder

    the folders are

    sessions
    logs
    tests
    cache/persistent
    cache/models
    cache/views

    2) then use the tortoisesvn > properties > new property > name is svn:ignore value is *

    on every 1 of the 6 above.

    3) commit the files AND folders so that the svn:ignore is propagated to server.

    problem solved. :)

    ReplyDelete
  3. A friend suggested this linux command line solution:

    To set the ignore I did the following:
    svn propedit svn:ignore app/tmp/cache/models/

    It pops up vi, and I entered a * and save the file. That tells it to ignore everything in that directory.

    ReplyDelete