Change svnroot

svn switch --relocate old_root new_root
svn switch --relocate svn+ssh:// file:///home/svn/svnroot
# Note that the old_root and new_root doesn't include the subdir:
# svn+ssh://
# not
# svn+ssh://

Importing existing directory structure into new svn repository


For existing files, create and import directory structure into a new svn repository.

# create repository
cd path/to/repo
mkdir svnroot
svnadmin create path/to/repo/svnroot
# change to the webroot directory
# normally includes the webroot / website directory 
# such as cd ~/Sites/8080/website
cd path/to/webroot
# import the files into the repository
# note the last path segment includes the webroot directory name
svn import file:///...path/to/repo/webroot
# move the original directory away and checkout the files 
cd ..
mv webroot webroot-preimport
svn co file:///...path/to/repo/webroot
# and into the webroot for editing
cd webroot
# actual history for cut and paste:
% pwd
% ls -1
% mkdir svnroot
% ls -1
% svnadmin create /home/kitt/sites/8080/svnroot
% cd website
% svn import file:///home/kitt/sites/8080/svnroot/website
% cd ..
% mv website website-preimport
% svn co file:///home/kitt/sites/8080/svnroot/website
A    website/a
A    website/a/index.php
A    website/index.php
A    website/.htaccess
Checked out revision 1.
% ls

Use alternate identity file for svn access with ssh


If you need a different identity file for ssh access when using svn (say, using your personal computer on a work project and need to keep the two identities separate when accessing a personal remote server), define the SVN_SSH shell variable to use the different identity file.

To specify a different identity file with ssh, use -i:

ssh -i /path/to/id_rsa

And define the SVN_SSH var.

export SVN_SSH="ssh -i /path/to/identity/file"

Deleting files using TortoiseSVN

Book page

When using TortoiseSVN (which, BTW, uses Drupal as it's website CMS, YAY!) as your interface to subversion, deleting files from the repository may not be obvious. To delete the files on your local checkout, first you indicate you want the files deleted, then you commit the deletion to the repository.

If you use the command line, the steps are:

% ls
dir1/           a-file.txt
% svn rm dir1
D         dir1/another-file-to-delete.txt
D         dir1/file-to-delete.txt
D         dir1
% svn ci -m "Removed the directory" dir1
Deleting       dir1

Committed revision 92.

With TortoiseSVN, you'll execute these same commands with the GUI, using your mouse instead.

First, select the file, files, directory or directories you want to delete.

Then, go to the menu: File > TortoiseSVN > Delete

You've now indicated to the subversion repository that you want to delete the selected files. To actually delete them, you need to commit your change.

Go to the menu File > SVN Commit

Don't forget to provide a good comment for your change! If you can, succinctly explain why you made your change, as well as the change you made.

svn: import in place

Book page

You have a set of files you want to import into an existing repository, but you want to keep them in place (say, a live website, where you want to create the repository without stopping the web services, or a working copy you want to keep working on).

These are the steps to import said files into an existing repository, keeping the files as a working copy (that is to say, import in place). They work because you can check out a (sub)directory from the existing repository directly into an existing directory.

Start by creating an empty directory in the repository, checking out this empty repository directory into the file system directory to be imported (making it now a working directory), then adding all of the files to the repository.


  1. Create a URL in the the repository that matches the top level of the files to be imported

    % svn mkdir file:///path/to/svn-repository/some/path/top-level-dir -m "Make dir in the repository corresponding to top-level-dir"

  2. Change to the top level directory of the files to be imported

    % cd top-level-dir

  3. Check out the top level directory just created in the repository

    % svn checkout file:///path/to/svn-repository/some/path/top-level-dir .

    This will create a .svn directory (with supporting files!) in the top-level-dir, since you just checked out the top of that path from the repository.

  4. Add all the remaining files to the repository

    % svn add file1 file2 dir1 dir2 ...

  5. And commit!

    % svn commit -m "Initial import of top-level-dir"


Book page

Subversion (svn) notes