Wednesday, August 22, 2007

Subversion

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 .


http://pandemoniumillusion.wordpress.com/2008/05/07/ignore-pyc-files-in-subversion/

http://svnbook.red-bean.com/en/1.0/re10.html
http://svnbook.red-bean.com/en/1.0/re36.html
http://aralbalkan.com/1381
http://svnbook.red-bean.com/en/1.1/svn-book.html#svn-ch-3-sect-6.2.2