0%

SVN Cheatsheet

SVN ( Sub version)是一套版本控制系统,用来管理文件和目录,以及对其进行的所有修改操作。

Components

组件 功能
svn Command line program
svnversion Revision of working copy
svnlook Inspect repository
svnadmin Repository administration
svndumpfilter Filter repository stream
mod_dav_svn Apache module
svnserve SVN server (SVN protocol)
svnsync Mirror repository

Protocols

协议 描述
file:// Local machine
http:// HTTP (Apache)
https:// HTTPS (SSL)
svn:// SVN (svnserve)
svn+ssh:// SVN over SSH

Help

1
$ svn help

SVN Help

1
$ svn help import

Show help for “import” command

Repo Admin

1
$ svnadmin create "/path/to/repository"

Create new repository

1
$ svnadmin setlog "/path" r 7 message.txt

Change log message for revision 7 to contents of file message.txt

1
$ svnadmin dump "/path/to/repository" > filename

Dump repository to file (backup)

1
$ svnadmin load "/path/to/repository" < filename

Load repository from file (restore)

Checkout

1
$ svn checkout "/path/to/repository"

Checkout working copy into current folder

1
$ svn checkout "/path/to/repository" "/path/to/folder"

Checkout working copy into target folder

Update

1
$ svn update "/path"

Update path

1
$ svn update -r9 "/path"

Update path to revision 9

Add Files / Folders

1
$ svn add *

Add all items, recursively

1
$ svn add itemname

Add itemname (if folder, adds recursively)

1
$ svn add * --force

Force recursion into versioned directories

Deleteing / Copying / Moving

1
$ svn delete "/path"

Delete path

1
$ svn -m "Delete message" delete "/path"

Delete with log message

1
$ svn copy "/source" "/target"

Copy source to target

1
$ svn move "/source" "/target"

Move source to target

Revert

1
$ svn revert "/path"

Revert changes to path

1
$ svn revert -R "/path"

Revert changes recursively

Commit

1
$ svn commit "/path"

Commit changes to path

1
$ svn commit -m "Message" "/path"

Commit with log message

1
$ svn commit -N "/path"

Commit without recursion

1
$ svn import "/path/to/folder" "/path"

Import and commit local folder

Logs and Blame

1
$ svn log "/path"

Show log messages for path

1
$ svn blame "/path"

Show commits for path

Differences Between Files

1
2
3
$ svn diff "/path/file"
$ svn diff "/path/file@2" "/path/file@7"
$ svn diff -r 2:7 "/path/folder"

Merge Changes

1
$ svn merge -r2:7 "item" "/path"

Apply diff between revisions 2 and 7 of “item” to path

1
$ svn merge "url1" "url2" "/path"

Apply diff between “url1” and “url2” to path

Miscellaneous

1
$ svn resolve "/path"

Resolve conflict

1
$ svn cleanup "/path"

Remove locks and complete operations

1
$ svn lock "/path"

Lock path

1
$ svn unlock "/path"

Unlock path

1
$ svn status "/path"

Get path status

1
$ svn cat "/path"

View file contents

Item and Property Statuses

指示符 含义
No modifications (blank)
A Addition
D Deletion
M Modified
R Item replaced
C In conflict
X Externals definition
I Ignored
? Not in repository
! Item missing
~ Object type changed

Argument Shortcuts

快捷写法 完整参数
-m “Message” –message
-q –quiet
-v –verbose
-r –revision
-c –change
-t –transaction
-R –recursive
-N –non-recursive

REFERENCE

http://svnbook.red-bean.com
http://overapi.com/svn