Frequently reoccurring svn task is: add an existing source tree as a new project in a svn-repository. Here's how I do it:
# done once and for all, this creates a template I use for all my svn-projects
# done only if you want a new repository (which may contain several projects)
svnadmin create /path/to/repository
# next, create a new empty project, called NewProject, by importing the template:
svn import -m "new app" ~/svn/project_template file:///path/to/repository/NewProject
# Next, cd to the parent of the new source directry, i.e. 'NewSourceDir' below should contain
# all files and directories you want to add to the trunk-directory of the svn-project. Next do:
svn co file:///path/to/repository/NewProject/trunk NewSourceDir
# this turns the NewSourceDir to working copy of trunk,
# but it doesn't add any of its content.
# So now it is time to start adding the stuff:
svn add X Y ...
# and finally a commit:
This is my preferred way of doing it since it lets me add the new stuff selectively. Rather than using 'svn import' to add everything at once, in which case I would first have to create a 'clean' copy of the new source. Hmm, i'm gonna put the above in a script so that I don't ever have to look at this post again :)
Just a note on
svn add. Default when add is applied to a directory is to add all its content recursively. To add only part of the content, use the
--depth flag. That is:
svn add --depth=empty NewDir
adds an empty
NewDir to the reporitory.
svn add --depth=files NewDir
adds NewDir and all files it contains, but leaves out directories.
svn add --depth=immediates NewDir
adds NewDir and all files and directories it contains, but not recursively.
Here's a link to another svn cheatsheet which covers some other tasks.