Original address: http://blog.csdn.net/sunboy_2050/article/details/6187464
SVN(Subversion) is a free, open-source project source code versioning tool. Currently, the vast majority of open source and Enterprise code management uses SVN as the code version management software.
Subversion stores files in the central repository, which is much like an ordinary file server. The difference is that it records the changes to each file and directory, so that you can restore the data to the previous version and see the details of the changes in the data when the rollback is needed.
SVN Official website: Apache Subversion
SVN server configuration: Install SVN server
One, SVN common commands
1. Checkout files to a local directory
SVN checkout Path (path is a directory on the server)
Shorthand: SVN Co
2. Add a new file to the repository
SVN Add File
3. Submit the changed files to the repository
SVN commit-m "LogMessage" [-n] [--no-unlock] PATH (use –no-unlock switch if hold lock is selected)
Shorthand: svn ci
4. Locking/unlock
SVN lock-m "Lockmessage" [--force] PATH
SVN unlock PATH
5. Update to a version
SVN update-r m path
Shorthand: SVN up
6. View file or directory status
1) SVN status path (status of files and subdirectories under directory, normal status not shown)
2) SVN status-v path (show file and subdirectory status)
Shorthand: SVN St
7. Delete Files
SVN delete path-m "Delete test Fle"
Shorthand: SVN (del, remove, RM)
8. View Logs
SVN log path
9. View File Details
SVN info Path
10. Compare Differences
SVN diff path (compares the modified file to the base version)
SVN diff-r m:n Path (difference between version m and version N)
Shorthand: SVN di
11. Merge the differences between the two versions into the current file
SVN merge-r m:n Path
12. SVN Help
SVN help
SVN help CI
second, svn not commonly used commands
13. List of files and directories under the repository
SVN list path displays all files and directories belonging to the repository in the path directory shorthand: SVN ls
14. Create a new directory under version control
SVN mkdir: Create a new directory under the included version control.
Usage:
1. mkdir PATH ...
Each directory specified in the working copy PATH will be created on the local side and added to the new schedule for the next commit.
2. mkdir URL ... Create a version-controlled directory.
Each directory specified in the URL is created by submitting it to the repository immediately. In both cases, all intermediate directories must exist beforehand.
15. Restore Local Modifications
SVN revert: Restores the original unchanged working copy file (restores most of the local modifications).
Usage: revert PATH ... Note: The notebook command will not access the network and will release the conflicting condition. But it does not restore the deleted directory
16. Code base URL Change
SVN switch (SW): Updates the working copy to a different URL.
Usage:
1. Switch URL [PATH]
Updating your working copy, mapped to a new URL, behaves like "SVN update" and merges the file on the server with the local file. This is the method that corresponds a working copy to a branch or tag in the same warehouse.
2. Switch--relocate from to [PATH ...]
Overwrites the URL metadata of the working copy to reflect the changes on the simple URL. When the repository's root URL changes (such as scheme name or hostname change), but the working copy is still mapped to the same directory as the same repository, use this command to update the corresponding relationship between the working copy and the warehouse.
17. Conflict resolution
SVN resolved: Removes the "conflicting" status of the working Copy's directory or file.
Usage: Resolved PATH ... Note: The book command does not resolve the conflict by syntax or remove the conflict token; it simply removes the conflicting file and then allows PATH to commit again.
18. Output the contents of the specified file or URL.
SVN cat Target [@ VERSION] ... If a version is specified, the lookup starts from the specified version. SVN cat-r PREV filename > filename (PREV is the previous version, you can also write a specific version number so that the output can be submitted)
Third, SVN other commands
Although not as common as the commands discussed earlier in this chapter, you sometimes need these commands.
SVN cleanup
When subversion modifies your working copy (or any information in. svn), it tries to be as secure as possible. Before changing a working copy, Subversion writes its intent to a log file. It then executes the commands in the log file to apply the required modifications. Finally, subversion deletes the log file. Architecturally, this is similar to a log file system (journaled filesystem). If a subversion operation is interrupted (for example, the process is killed, or the machine is lost), the log file is still on the hard disk. Re-executing the log file, subversion can complete the previous operation so that your working copy can return to a reliable state.
Here's what SVN cleanup does: It searches your working copy and executes all the remaining logs, removing the lock during this process. If subversion has told you that part of your working copy is "locked", then you should execute this command. In addition, SVN status displays L before locked items.
$ SVN status
L Somedir
M SOMEDIR/FOO.C
$ svn cleanup
$ SVN status
M SOMEDIR/FOO.C
SVN import
Using SVN import is a quick way to copy the non-versioned file tree to the repository, and it needs to create a temporary directory.
$ svnadmin Create/usr/local/svn/newrepos
$ svn Import mytree File:///usr/local/svn/newrepos/some/project
Adding MYTREE/FOO.C
Adding mytree/bar.c
Adding Mytree/subdir
Adding mytree/subdir/quux.h
Committed Revision 1.
The above example copies the contents of the Mytree directory under the Some/project directory to the repository.
$ SVN List File:///usr/local/svn/newrepos/some/project
Bar.c
Foo.c
subdir/
Note After the import is complete, the original tree is not converted to a working copy. To get started, you still need SVN checkout a new working copy of the tree.
Iv. List of common SVN commands
Command |
Function |
Use formatting |
Checkout |
Check out |
SVN Co URL |
Up |
Update to the end of the current URL |
SVN up |
Switch |
Update to a Tag/branch |
SVN switch (tag/branch) URL |
Add |
Increase |
SVN Add file name |
Rm |
deleting files |
SVN rm file name |
Delete Directory |
SVN RM Directory Name |
Diff |
vs. base version (last checked out or updated to version) |
SVN diff |
Compare to the latest version in the Repository |
SVN diff-r Head |
Current working copy, comparison between two versions |
SVN diff-r Reversion1:reversion2 |
Compare any two tags in the repository |
SVN diff (tag1) url (tag2) URL |
Ci |
Submit |
SVN ci-m "Commit log" |
Log |
View current Working copy log |
SVN log |
View only the specified version of log |
SVN log-r |
Print log all additional information |
SVN log-v |
View current Tag/branch version details |
SVN log--stop-on-copy-v |
Info |
View the URL of the current working copy |
SVN info |
Status |
View the status of a working copy |
SVN St |
View the taglist of a file |
SVN command not supported, can execute CS taglist |
Tag |
Add tag |
SVN CP. (tag) URL |
Delete tag |
SVN rm (TAG) url-m "Commit Log" |
Overwrite tags that already exist |
Not supported |
Branch development |
Create Branch |
SVN CP (Baseline version) URL (branch) url-m "Commit Log" |
Delete Branch |
SVN rm (branch) url-m "Commit Log" |
Synchronous |
SVN Co (trunk) URL |
CD ~/WC |
SVN merge (trunk) URL (to sync tag) URL |
SVN ci-m "Commit log" |
SVN cp (trunk)URL ( tag ending with _pd_bl_main )url-m "Commit log" |
Merge |
SVN Co (merge target) URL |
CD ~/WC |
SVN merge (baseline version tag) URL (line tag) URL |
SVN ci-m "Commit log" |
SVN cp (merge target) URL (Tag_merge_ tag for online) url-m "Commit Log" |
SVN instance
Delete all the. SVN hidden subdirectories under the directory
find
. -name ".svn" -print0 |
xargs
-0
rm
-rf
Tags score Branch
SVN cp trunk/tags/platform_2011.11.11 (or SVN cp HTTP://192.168.1.100/PLATFORM/TRUNK/HTTP://192.168.1.100/PL atform/tags/platform_2011.11.11)
SVN ci-m "svn cp trunk/tags/platform_2011.11.11"//Submit and give the commit record (-M "SVN CP trunk/tags/platform_201 1.11.11 ")
SVN renaming
SVN mv platform_2011.11.11 platform_20111111
SVN ci-m "svn mv platform_2011.11.11 platform_20111111"//Submit
SVN directory is missing
1) svn up missingdirname
2) SVN del missingdirname
3) svn ci
SVN Chech version
SVN Co http://192.168.1.100/platform/branch-r platform_branch_v12
SVN log
SVN log http://192.168.1.100/platform/branch-l10//SVN text comment log
SVN log http://192.168.1.100/platform/branch-l10-v//SVN text comment log + file update log (add, delete, change)
SVN diff-r v_1:v_2 Svn_path
SVN diff-r 200:201 test.php
View SVN version
Svnserve--version
Ubuntu Install SVN 1.7, 1.8
Currently in Ubuntu 12.04, the SVN version is 1.6, this version will create a new. SVN directory in each subdirectory to save the version file, very uncomfortable. Find a third-party compiled Ubuntu Source:
1) Open Source.list Source:
sudo vi/etc/apt/sources.list
2) Add source
Deb Http://ppa.launchpad.net/dominik-stadler/subversion-1.7/ubuntu Precise Main
Deb-src Http://ppa.launchpad.net/dominik-stadler/subversion-1.7/ubuntu Precise Main
3) Execute the installation command
sudo apt-get install subversion
Reference recommendation:
Git common commands in a detailed
Git Version Management Tools
Git Common Command Quick Check table
SVN add new Project under Ubuntu Environment (recommended)
SVN Online Code hosting Tool
SVN common commands