Subversion

How to remove .svn folders from a directory tree in one line

find . -name ".svn" -type d -exec rm -rf {} \;

Add a directory to an existing repository

N.B. You must add the target directory name to the URL (e.g. sql below).

N.B. You must be in the relevant directory (e.g. sql below).

jn9ky0j-msd:sql admin$ ls -al
total 16
drwxr-xr-x   3 admin  staff   102 21 Oct 16:16 .
drwxr-xr-x  71 admin  staff  2414 21 Oct 16:16 ..
-rw-r--r--   1 admin  staff  6777 21 Oct 15:54 mahara_pp_alter_table_collate.sql
jn9ky0j-msd:sql admin$ svn import http://svn.ucl.ac.uk/repos/mahara/sql
Adding         mahara_pp_alter_table_collate.sql

Committed revision 46.
jn9ky0j-msd:sql admin$
 

Delete a file from a repository

svn delete — Delete an item from a working copy or the repository.

svn delete PATH...

svn delete URL...

Free Hosting

See Project Management

Ignoring files

svn propset svn:ignore *.class .

N.B Final . in above

Ignoring a directory

svn propset svn:ignore tmp .

To check what is being ignored

svn propget svn:ignore

Reverting to an older version of whole project

svn merge —dry-run -r555:540 [http://wasdev-b.ucl-0.ucl.ac.uk/repos/OLM/trunk/OLM] (!) Dry run only

svn merge -r555:540 [http://wasdev-b.ucl-0.ucl.ac.uk/repos/OLM/trunk/OLM] (!) Real thing

Reverting to an older version of a file

Find the relevant revision number of that file in Trac, download, then move to the right directory.

Creating a new repository (20-4-09)

sudo svnadmin create /var/lib/svn/$NEW_REPOS

sudo chown -R www-data:www-data /var/lib/svn/$NEW_REPOS

sudo chmod -R g+ws /var/lib/svn/$NEW_REPOS

sudo svn mkdir file:///var/lib/svn/$NEW_REPOS/branches file:///var/lib/svn/$NEW_REPOS/tags file:///var/lib/svn/$NEW_REPOS/trunk -m "initial setup"

sudo vim /etc/apache2/mods-available/dav_svn.conf
   * Add <Location> section for the new repository

To add a project

Do not forget to add the project name, otherwise you will create n directories of projects.

svn import . -m 'Initial import' [http://128.40.222.167/svn/AB_TEST/trunk/newsletter]

{warning}Do not forget the -m
{warning}
otherwise you will go into the default editor.&nbsp;&nbsp; Also notice that importing an initial version into the repository does *not* check out a working version.&nbsp; So rename the original directory and go straight to checking out a working copy.

mv [newsletter] [newsletter]_OLD

svn co [http://128.40.222.167/svn/AB_TEST/trunk/][newsletter]

To delete a project:

When logged into [http://128.40.222.167] you can use localhost

svn delete -m "Deleting project dir" [http://128.40.222.167/svn/AB_TEST/trunk/ruby]

will *delete* and *commit* that deletion.
svn co [http://128.40.222.167/svn/AB_TEST/trunk/user_group]

but make sure you are in the right directory first.
For RoR you may need to run:
rake db:create
rake db:migrate

To check status

svn status

To check changes

svn diff

To add new directories:

svn add ./test/unit ./db/migrate

To ensure ALL files are added:

svn add ./*

To commit changes

svn commit -m 'DB: 1' .

Sample shell script for RoR projects

#!/bin/sh
svn remove log/*
svn commit -m"removing log files"
svn propset svn:ignore "*.log" log/
svn update log/
svn commit -m 'Ignoring all files in /log/ ending in .log'
svn move config/database.yml config/database.example
svn commit -m 'Moving database.yml to database.example to provide a template for anyone who checks out the code'
svn propset svn:ignore "database.yml" config/
svn update config/
svn commit -m 'Ignoring database.yml'
svn remove tmp/*
svn propset svn:ignore "*" tmp/
svn update tmp/
svn commit -m "ignore tmp/ content from now"
svn propset svn:ignore ".htaccess" config/
svn update config/
svn commit -m 'Ignoring .htaccess'
svn propset svn:ignore "dispatch.fcgi" config/
svn update config/
svn commit -m 'Ignoring dispatch.fcgi'

What to do when subversion refuses to svn add a directory:
1) cd into that directory

2) rm -rf .svn

3) Go back to the root dir and rerun svn add

svn switch

$ svn switch --relocate [http://128.40.222.167/svn/AB_TEST/trunk/php&nbsp]; [http://wasdev-b.ucl-0.ucl.ac.uk/repos/AB_TEST/trunk/php]

Links

Subversion cheat sheet [http://www.digilife.be/quickreferences/QRC/Subversion%20Quick%20Reference%20Card.pdf]
SCN book[http://svnbook.red-bean.com/nightly/en/svn-book.pdf]

Sample shell script for RoR projects

#!/bin/sh
svn remove log/*
svn commit -m"removing log files"
svn propset svn:ignore "*.log" log/
svn update log/
svn commit -m 'Ignoring all files in /log/ ending in .log'
svn move config/database.yml config/database.example
svn commit -m 'Moving database.yml to database.example to provide a template for anyone who checks out the code'
svn propset svn:ignore "database.yml" config/
svn update config/
svn commit -m 'Ignoring database.yml'
svn remove tmp/*
svn propset svn:ignore "*" tmp/
svn update tmp/
svn commit -m "ignore tmp/ content from now"
svn propset svn:ignore ".htaccess" config/
svn update config/
svn commit -m 'Ignoring .htaccess'
svn propset svn:ignore "dispatch.fcgi" config/
svn update config/
svn commit -m 'Ignoring dispatch.fcgi'

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License