Wednesday, August 22, 2007


Setting up a repository:
svnadmin create /usr/local/svn/newrepos

Import files into repository:

svn import /import/dir file:///usr/local/svn/newrepos/projectname -m "comment"

List files in a repository tree:

svn list file:///usr/local/svn/newrepos/projectname
svn ls #while in sandbox
svn ls -v # verbose

Checkout a directory:

svn checkout "http://host:port/path"
svn co http://host:port/path
svn checkout file:///path/to/repos
svn checkout file:///localhost/path/to/repos
svn checkout svn+ssh://host/path/to/repos

Check a specific revision:
svn checkout -r revision_num
svn checkout -r {2006-02-17}
svn checkout -r {"2006-02-17 15:30"}

Checkin a file:
svn commit filename.txt -m "some comment here"

Update working copy with committed changes from other users:
svn update

Manage local copy (sandbox):
svn add filename
svn delete filename
svn move file1 file2
svn copy file1 file2
svn mkdir dirname

View files changed since last commit:
svn stat
svn stat filename
svn status -v # verbose view of all files in sandbox
svn status -v -u # contacts the repository to show more info

View changes since last commit:
svn diff # show diffs within files

Revert a file (working copy):
svn revert file

Restore a previously committed file back to working copy:
svn merge -r curr_version:prev_version working_file.txt

Show revision history:
svn log
svn log -r 5:19 # shows revisions 5 through 19
svn log -r 9 # shows revision 9
svn log filename # show revisions on a given file
svn log -r {2006-11-20}:{2006-11-22} # show versions between two dates
svn log --verbose # show all files in all revisions
svn log --verbose | grep "/path/to/file/" -B10 # grep history and show last 10 lines

Show file info:
svn info filename

Backup a repository:
svnadmin dump
/path/to/repository > dumpfile

Restore a repository:

svnadmin load
/path/to/repository/ < dumpfile.dump

Export a repository without all the metadata:
svn export file:///path/to/repository export_dir

Ignore files in the svn working copy:
create a file in home directory called .svnignore 
While in working copy, run command
svn -R propset svn:ignore -F /path/to/home/.svnignore .


Louis Ramos said...

Thanks Joe, this was helpful :)

Louis Ramos said...

Getting this error?
svn: Expected FS format '2'; found format '3'

1. Move the repos to your workstation or a server with the latest subversion

(old server svn 1.4.6)
tar -czf the_repos.tar.gz the_repos
scp the_repos.tar.gz ...
rm the_repos.tar.gz

2. Convert old svn repository:

(workstation svn 1.6.5)
tar -xzf the_repos.tar.gz
rm the_repos.tar.gz
mv the_repos the_repos_old
svnadmin create --pre-1.5-compatible the_repos
svnadmin dump the_repos_old | svnadmin load the_repos
tar -czf the_repos.tar.gz the_repos/
scp the_repos.tar.gz ...

3. Extract the new repos in original location.
tar -xzf the_repos.tar.gz

4. Checkout. Done.


Louis Ramos said...

change repos location:

svn switch --relocate svn+ssh:// svn+ssh://