Dave Perrett

Subversion Commands

linux, programming, subversion, version control

Common Commands

Version information

1
$ svn info

See changed files

1
$ svn stat

See updated files

1
$ svn stat -u

Commit changes

1
$ svn commit -m "message" /path/to/file1 /path/to/file2 /path/to/file3

Undo changes

1
$ svn revert /path/to/file

Check out latest version

1
$ svn co svn://localhost/trunk/ /path/to/folder/

Check out old version

1
$ svn co -r 123 svn://localhost/trunk/ /path/to/folder/

Add file (need to commit after)

1
$ svn add /path/to/new/file

Delete file (need to commit after)

1
$ svn remove /path/to/file

Copy file (copy history from the file to the new one - need to commit after)

1
$ svn copy /path/to/file /path/to/newfile

Move file (retains history from the old file to the new one - need to commit after)

1
$ svn move /path/to/oldfile /path/to/newfile

See file changes

1
$ svn diff --diff-cmd /usr/bin/diff -x "-bB" /path/to/file

Other Commands

Ignore directories / files when they are recreated or keep changing (you may need to do an ‘svn update’ after this before you can commit)

1
$ svn propset svn:ignore "file.extension" directory

Merge changes into a directory

1
$ svn merge -r 123:234 svn://localhost/trunk/ /path/to/folder/

Compare branch against a directory - useful before merging ( dry run shows the results that would happen if you did a merge )

1
$ svn merge -r 123:456 svn://localhost/branches/branch /path/to/folder/ --dry-run

Switch to a different version

1
$ svn switch -r 123 svn://localhost/trunk/ /path/to/folder/

Edit a commit comment

1
$ svn propedit svn:log --revprop -r 123 svn://localhost/trunk --editor-cmd vi

See subversion history

1
$ svn log svn://localhost/trunk --stop-on-copy --verbose

Create a new repository

1
2
3
$ svnadmin create /home/svn_repository
$ cd /home
$ mkdir svn_repository

Import files into a repository

1
$ svn import /path/to/project svn://localhost/trunk -m "message"

Create a new branch

1
$ svn copy -r 123 svn://localhost/trunk svn://localhost/branches/name -m "message"