SVN Version Control
What is SVN?
SVN (Subversion) is a version control tool that can manage program files by version.
checkout (co)
Fetch source code from a repository into a local working space.
Usage
svn checkout [SVNURL] [checkout target]
Example
$ svn checkout https://desktop-8kkel5e/svn/kimkc/
Checked out revision 0.
add
Add a file or directory to be managed by SVN. After adding it, you must run commit to reflect it in the repository.
Usage
svn add [file name to add]
Example
$ svn add Test.java
A Test.java
$ svn commit
adding Test.java
commit (ci)
Apply locally modified content to the repository.
Usage
svn commit [file name to commit] -m [message to leave in the log]
Example
$ svn commit Test.java -m "test"
Adding Test.java
Transmitting file data .done
Committing transaction...
Committed revision 1.
update (up)
Update local source code with the latest contents from the repository.
Usage
svn update
Example
$ svn update
Updating '.':
At revision 3.
delete(del, remove, rm)
Delete a file or directory managed by SVN. After deleting it, you must run commit to reflect the change in the repository.
Usage
$ svn delete [file name to delete from the SVN managed list]
Example
$ svn delete text.txt
D text.txt
$ svn commit
Deleting test2.c
Check changed file status in SVN
Usage
svn status
Check repository URL
Usage
$ svn info
Path: .
Working Copy Root Path: D:\svn-file-test\kimkc
URL: https://desktop-8kkel5e/svn/kimkc
Relative URL: ^/
Repository Root: https://desktop-8kkel5e/svn/kimkc
Repository UUID: 08d25a28-c52d-f14b-9aa0-5c24a007a8d5
Revision: 0
Node Kind: directory
Schedule: normal
Last Changed Rev: 0
Last Changed Date: 2019-07-30 09:50:14 +0900 (화, 30 7 2019)
log
View file modification history in the repository.
Usage
$ svn log [PATH]
For more detail:
$ svn log -v
$ svn log
------------------------------------------------------------------------
r3 | kimkc | 2019-07-30 13:52:22 +0900 (화, 30 7 2019) | 1 line
test3
------------------------------------------------------------------------
r2 | kimkc | 2019-07-30 11:14:30 +0900 (화, 30 7 2019) | 1 line
test2
------------------------------------------------------------------------
r1 | kimkc | 2019-07-30 10:00:24 +0900 (화, 30 7 2019) | 1 line
test
------------------------------------------------------------------------
$ svn log -r 30:100 test.c
Print the log for test.c between revision numbers 30 and 100.
blame
Check who modified each line.
Example
$ svn blame sample.c
export
Fetch only the original files from the repository.
Usage
svn export [SVNURL] [destination]
Example
$ svn export http://svn.bds.fbwotjq.com/www/manager/trunk/ docs_manager
Export only a specific revision
Because export retrieves only the pure source files and excludes version control metadata, it is often used for source releases. You can specify the -r option to fetch the source for a specific revision.
Usage
svn export [SVNURL] [destination folder] -r [revision number]
Example
svn export https://desktop-8kkel5e/svn/www/manager/trunk/ docs_manager -r 186
import
Usage
svn import [target to upload] [SVNURL] -m [message to leave in the log]
Example
$ svn import docs_js https://desktop-8kkel5e/svn/www/manager/trunk/ -m "svn import test"
info
View information about the currently connected SVN file repository.
$ svn info
Example
$ svn info
Working Copy Root path : /home/
URL : http://192.168.0.1/project
Relative URL : ...
update
Fetch the latest changes stored in the current file repository.
Usage
svn update
Example
$ svn update
Updation '. :
At revision 1111.
diff
Compare the contents of modified files.
Usage
svn diff --revision [number part of the r number checked in the log above] [file name to compare]
Example
$ svn diff --revision 1111 test.c
===================================
--- //test log
+++//new log
....
relocate
When the repository URL changes, change the URL locally.
Usage
SVN 1.6 or earlier
svn switch --relocate {old URL} {new URL}
SVN 1.6 or later
svn relocate {new URL}
$ svn relocate https://svn.devkuma.com/svn/kimkc
Check the current SVN version
$ svn --version