How do I exclude the /log directory from svn repository?

Every open source program comes with a vital instruction(s) that is
(are) deliberately left out of the documentation so as to differentiate
the pros from the newbies. In this case the svn documentation doesn’t
tell you straight out how to exclude files, which means that if you
blindly go ahead and import a standard rails directory structure you can
end up with massive and entirely useless log files in your repository
unless you do something about it.

After much hunting around the net, the documentation, the help lists
I’ve discovered a little talked about, but totally crucial command, svn
propset svn:ignore

which has the useful comment in the help screens
svn:ignore - A newline separated list of file patterns to ignore.

Now that clearly tells everything a pro needs, but for a newbie like me
leaving out the issue of how to put a newline into a list of file
patterns when you’re typing from the command line renders the
instruction useless. Yes I admit it, I’m a total newbie I can’t put a
newline into a command line string without hitting the Enter key. Please
can someone tell me how to do it. I guess I could create a file of file
patterns I want ignored and pipe that in, but it seems a bit excessive.

I’m asking it here because it has to be a problem that everyone using
rails and svn must have run into. There’s virtually nothing about it


John S.

You want to keep the log directory, because rails needs it to run.
What you want to do is ignore any files in the log directory.

Your project must already be tracked by svn in order to ignore files.
Assuming it is, first, remove any files in the log directory and

$ svn rm log/*
$ svn ci -m “removing log files”

Second, ignore any files in the log directory and commit.

$ svn propset svn:ignore “*” log/
$ svn ci -m “ignoring log files”

If you ever need to edit an svn property with multiple entries, look
up svn:propedit and the SVN_EDITOR environment variable, which is just
one means of telling svn what text editor to invoke when you run
svn:propedit (and other commands).

Now, if your project is not yet tracked by svn, then remove any files
in the log directory, import the project, set svn:ignore on the log
directory as we did earlier and commit.

By the way, the reason that I like to include the empty log directory
in svn is so that other developers can just checkout the code and get
to work; there’s no little step of remembering to create the log dir.
I used to do the same for the tmp dir as I described for the log dir,
but Rails 2.1 creates the tmp dir if doesn’t already exist.



I would rather use a more restricted pattern.

$ svn propset svn:ignore “*.log” log/

I want ‘svn st’ to let me know if something different than a log
file exists in the log/ folder

Aníbal Rojas


Thanks for that.

I also found a neat little rake task at which sets things up for
Rails. The comments after that posting indicate that it should work
wonderfully. Though of course it doesn’t. I have to sort out what’s
going on with my svn to get it to work. There’s always little tricks and
tweaks required.


John S.