From: http://blog.csdn.net/cb_121/archive/2008/10/28/3167901.aspx
Basic usage
SVN is the next version of CVS. It is mainly used for version control. It can control the version of program code, audio, video, and image files.
Directories and files are objects that can be recorded in subversion. Its main working principle is as follows:
__________
//
|
| Project repository |
|
/__________/
/|
/Check in |
Check out/|
_/_ | _______
////
|
| Work copy |
|
/________//________/
Branch, trunk, merge, label
When creating a branch or tag, a "delayed copy" technology is used, that is, only links pointing to the same version are created. When a file is changed, copy the file or directory.
Generally, a branch is used to prepare for release, rather than parallel development.
1. Create a project warehouse
Svnadmin create/home/Huzza/test_svn
2. Import the initial file to the project repository.
SVN import-M source_file_path URL
URL in this example: file: // home/Huzza/test_svn/sesame/trunk
File: // ------> tell SVN to be a local directory
3. Run the checkout file to the local directory.
SVN checkout (CO) file: // home/Huzza/test_svn/sesame/trunk
4. Check the file status or log
SVN status [file/directory]
SVN log [file/directory]
SVN log-R6: 8 [file/directory] view logs between version 6 and version 8
5. File/directory comparison (Work copy and project-Created database comparison)
SVN diff [file/directory] Or SVN diff -- rhead [file/directory] -- rhead: indicates the latest version.
6. update local work copy and submit work Modification
SVN Update (up) [file/directory]
SVN checkin (in)-M "Comments" [file/directory]
Some file flags during update:
U ------ indicates the file is updated.
G ------ indicates that the files in the project's database are merged with the files copied locally.
C ------ indicates that a conflict occurs during merge.
A ------ a new file is added.
D ------ deleted an object
? ------ Indicates that the file or directory is not managed by SVN
M ------ the file is modified
7. Conflict. If a file conflict exists during SVN update, open the file conflict, <and >>>>>> indicates the location where the conflict occurred.
When a conflict occurs, if you want to use the version in the project repository without modifying the local copy, you can use the following command:
A. SVN revert [conflicting files/directories]
B. SVN update [conflicting files/directories]
(SVN resolved [file/directory] & SVN updata [file/directory], which also seems OK. You need to confirm it)
If you want to retain the modification of the local copy of work and discard the modification of the version in the project repository, you can:
A. CP file/directory. Mine file/directory
B. SVN resolved file/directory
C. SVN ci-M "use my version please" file/directory
(In the above three steps, it seems that you can achieve the goal without performing step)
8. Connect the svn project repository to the Internet
Start the svn server: svnserve -- daemon -- root/home/Huzza/test_svn
Column server resources: SVN list SVN: // 192.168.0.4/sesame/trunk
The URLs are different, and the parts of other operations are the same.
SVN + SSH access: SVN list SVN + SSH: // 192.168.0.4/sesame/trunk (SSH access is required on the server)
9. Get a working copy of a specific version.
SVN checkout-rversionnum list SVN: // 192.168.0.4/sesame/trunk butterfly
SVN info butterfly (view the copy status of the current version)
10. Copy/move a file
SVN copy filename newfile
SVN move oldfile newfile
SVN ci-M "Add or move some files" [modify the directory where the file is located] (make sure that the same action is performed on the server as on the local copy)
11. Version symbols
Head --------- the latest version in the project Repository
Base --------- baseline version of The Work copy (that is, the version when the checkout is released)
Committed ---- the last checkin version
Prev --------- a previous version of committed
12. Search for differences between versions
SVN diff-R2: 4 [file/directory]
SVN diff> diffname. Patch (generate the patch file)
Use the patch file: patch-P0-I diffname. Patch
13. Delete the last version and modify the previous version.
SVN merge-r27: 26 [file/directory] & SVN ci-M "undo the work of version 27"
Undo the modification made by version 27
14. Create branch/label
SVN mkdir-M "create branches" SVN: // 192.168.0.4/sesame/branches
SVN copy-M "create release branches for version 1.0" SVN: // 192.168.0.4/sesame/trunk/
SVN: // 192.168.0.4/sesame/branches/release-1.0