svn cheatsheet

resolve tree conflict

Sometimes you got tree conflict in your working copy, such as:

  1. you modified a file in FooDir;
  2. another colleague removed the directory and committed, or you switched to another branch;
  3. when you update, you got a tree conflict;

To resolve this conflict:

  1. backup any local edit you need;
  2. remove the directory: rm -rf FooDir;
  3. svn revert FooDir;
  4. svn up FooDir;
  5. apply any local edit you have backed up;

list repo contents

$ svn list svn://

update svn external links


$ svn propedit svn:externals <svn-repo-path> --editor-cmd "echo languages <external-repo-path> >"
$ svn propedit svn:externals svn://[分支]/includes --editor-cmd "echo languages svn://>"

setup a svn server

$ sudo mkdir -p /data/svn
[sudo] password for lee: 
$ cd /data/svn/

# create a demo repo 'helloSvn'
$ sudo svnadmin create helloSvn
$ sudo chown -R lee:lee helloSvn/
$ ls

# start svn server
$ svnserve -d

# checkout the repo using a local file path
$ svn checkout file:///data/svn/helloSvn/
Checked out revision 0.

add http support:

# if apache is already installed, install apache's svn module
$ sudo apt-get install libapache2-svn

# generate a password file
$ sudo htpasswd -c -b -m /etc/apache2/dav_svn.passwd guisheng 123456

add a new vhost, /etc/apache2/sites-available/svn.local

<VirtualHost *:80>
    ServerName svn.local
    DocumentRoot /var/www
    <Location /svn>
        DAV svn
        SVNParentPath /data/svn
        SVNListParentPath On

        AuthType Basic
        AuthName "Subversion Repository"
        AuthUserFile /etc/apache2/dav_svn.passwd
        Require valid-user

enable the vhost:

$ sudo a2ensite svn.local
$ sudo service apache2 restart

now visit http://svn.local/svn/

or checkout the repo like this:

$ svn co --username guisheng http://svn.local/svn/helloSvn

set svn properties

edit ignore files list for current directory

$ svn propedit svn:ignore .

ignore a folder when update

for example, i want to exlucde the tags folder from updating, do this:

$ svn update --set-depth=exclude tags

after this, any svn up will not update the tags folder

global ignore pattern

set global ignore pattern in ~/.subversion/config

revert a commit

e.g. you just commit revision 4699, you want to revert the change, do this:

svn merge -c -4699 .