Common SVN commands (comprehensive and practical)

Source: Internet
Author: User
Tags subversion client svn update
Install the Subversion client in Ubuntu:

Sudo apt-getinstall subversion-Tools

1. Check out SVN Co http ://PATH (full directory or file path) [full local directory path]

 -- UsernameUser Name

-- PasswordPassword

SVN Co SVN ://PATH (full directory or file path) [full local directory path]-- UsernameUsername -- Password
SVN checkout http ://PATH (full directory or file path) [full local directory path]-- UsernameUser Name
SVN checkout SVN ://PATH (full directory or file path) [full local directory path]-- UsernameUser Name
Note: If the -- password parameter is not included, the system will prompt you to enter the password. We recommend that you do not use the -- password option in plain text.
Username and password are two short-term, not one.
If the full path of the local directory is not specified, the local directory is checked out.
Example:
SVN Co SVN ://192.168.0.3/Test Tool/Home/testtools -- username Luke
SVN Co http ://
192.168.0.3/test/testapp-- Username Luke
SVN checkout SVN ://
192.168.0.3/Test Tool/Home/testtools -- username Luke
SVN checkout http ://
192.168.0.3/test/testapp-- Username Luke

 

2. Export (Export a directory tree without a. SVN folder )

SVN export [-R version] http: // path (full path of directory or file) [full path of local directory] -- username Username
SVN export [-R version] SVN: // path (full path of directory or file) [full path of local directory] -- username Username
Local directory full path (with. SVN folder) detected by SVN export to Be Exported

Note: The first method to export the working directory tree from the version library is to specify the URL,
If the version number is specified, the corresponding version is exported,
If no version is specified, the latest version is exported to the specified location.
If the full path of the local directory is omitted, the last part of the URL is used as the name of the local directory.
The second method is to specify the full path of the local directory to be exported. All local modifications will be retained,
But files that are not under Version Control (that is, new files that are not submitted, because there is no related information record in the. SVN folder) will not be copied.
Example:
SVN export SVN: // 192.168.0.3/test tool/home/testtools -- username Luke
SVN export http: // 192.168.0.3/test/testapp -- username Luke
SVN export/home/testapp/home/testtools


3. Add a new file SVN addFile Name
Note: Tell the svn server to add files and use SVN commint-m to upload files!
Example:
SVN add test. php add test. php
SVN commit-M "add my test with test. php" test. php
SVN add *. php add all PHP files in the current directory
SVN commit-M "add my tests with all PHP files" *. php

4. Submit SVN commit-m"Submit remarks" [-N] [-- no-unlock]File Name
SVN ci-m"Submit remarks" [-N] [-- no-unlock]File Name
The-M parameter must be included. The parameter can be null, but it must be written as-M.
Example:
SVN commit-M "submit all files in the current directory under Version Control" * Note this * indicates all files
SVN commit-M "submit my test with test. php" test. php
SVN commit-M "submit my test with test. php"-N -- no-Unlock test. php keep the lock and use the-no-Unlock switch.
SVN ci-M "submit all files in the current directory under Version Control" * Note this * indicates all files
SVN ci-M "submit my test with test. php" test. php
SVN ci-M "submit my test with test. php"-N -- no-Unlock test. php keep the lock and use the-no-Unlock switch.

5. Update files SVN update
SVN Update-R
Revised version file name
SVN updateFile Name
Example:
There is no directory after SVN update. By default, all files in the current directory and subdirectory are updated to the latest version.
SVN update-r 200test. cpp: restores the file test. cpp in the version Library to the revised version (revision) 200.
SVN update test. php updates are synchronized with version libraries.
An expiration conflict is prompted during submission. You need to update and modify the file first,
Then clear the svn resolved and submit the commit.

6. delete an object SVN delete SVN ://PATH (full directory or file path) -M"Delete remarks text"
The following operations are recommended:
SVN DeleteFile Name
SVN ci-m"Delete remarks text"
Example:
SVN delete SVN: // 192.168.1.1/testapp/test. php-M "delete test file test. php"
The following operations are recommended:
SVN delete test. php
SVN ci-m "delete test. php"

7. Lock/unlock SVN lock-m"Lock remarks text" [-- Force]File Name
SVN unlockFile Name
Example:
SVN lock-M "test the test. php file" test. php"
SVN unlock test. php

8. Differences SVN diffFile Name
SVN diff-RCorrected version m :Corrected version n  File Name
Example:
SVN diff test. php compares the modified file with the basic version
SVN diff-r 200:201 test. php differs in version 200 and version 201.

9. view the file or directory status SVN StDirectory path/Name
SVN statusThe status of the files and subdirectories in the directory path/name directory. The normal status is not displayed.
【? : Not under SVN control; M: The content is modified; C: A conflict occurs;
A: To be added to the version Library; K: locked]
Svn-VDirectory path/Name
SVN status-VDirectory path/Name: displays the file and subdirectory status
[The first column remains the same, and the second column displays the working version number,
The version number and modifier of the last modification are displayed in columns 3 and 4]
Note: SVN status, SVN diff, and SVN revert commands can be executed without a network,
The reason is that SVN retains the original copy of the local version in local. SVN.

10. View logs SVN logFile Name
Example:
SVN Log Test. php displays all the changes to this file and their version numbers.

11. View File details SVN infoFile Name
Example:
SVN info test. php

12. SVN help SVN helpAll function options
SVN helpDescription of specific CI Functions

13. view the files and directories in the version Library SVN list SVN ://PATH (full directory or file path)
SVN ls SVN ://PATH (full directory or file path)
Example:
SVN list SVN ://192.168.0.3/test
SVN ls SVN ://192.168.0.3/test display SVN ://All files and directories belonging to the version library under the 192.168.0.3/test directory

14. Create a new directory under Version Control SVN mkdirDirectory Name
SVN mkdir-m"Add directory remarks" Http ://Full directory path
Example:
SVN mkdir newdir
SVN mkdir-M "making a new dir." http: // 192.168.0.3/test/newdir
Note: After adding a subdirectory, you must update it in the root directory. Otherwise, a message indicating "failed to submit" is displayed when you submit the file in this directory"
SVN update
Note: If you manually create a new folder newsubdir in the directory that comes out of checkout,
After the svn mkdir newsubdir command is used, SVN will prompt:
SVN: how to replace "SVN Add" or "SVN add -- Non-recursive?
SVN: Unable to create directory "Hello": the file already exists
Run the following command to solve the problem:
SVN add -- Non-recursive newsubdir
In the newsubdir folder, use LS-a to view all the directories and files under it, and you will find more:. SVN directory
Run the svn mkdir-M "add Hello function module File" SVN: // 192.168.0.3/test/newdir/newsubdir command,
SVN prompt:
SVN: file already exists: filesystem '/data/svnroot/test/db', transaction '2017-1 ',
Path '/newdir/newsubdir'

15. Restore local modification SVN revert [-- Recursive] File Name
Note: The sub-commands do not access the network and will release the conflict. However, it does not restore the deleted directory.
Example:
SVN revert Foo. c discards modifications to a file
SVN revert -- Recursive. Restore the entire directory file. It is the current directory

16. Copy the job and update it to another URL. SVN switch http ://Directory full path local directory full path
Example:
SVN switch http: // 192.163.0.3/test/456. (originally the 123 Branch) branch of the current directory to 192.163.0.3/test/456

 

17. Conflict Resolution SVN resolved[Local directory full path]
Example:
$ SVN update
C Foo. c
Updated to Revision 31.
If you get a conflict during the update, your work copy will generate three new files:
$ Ls
Foo. c
Foo. C. Mine
Foo. C. R30
Foo. C. R31
When you solve the foo. c conflict and are ready to submit, run SVN resolved to let your work copy know that you have done everything.

You can only delete and submit conflicting files. However, in addition to deleting conflicting files, SVN resolved also fixes record data in the work copy management area. Therefore, we recommend that you use this command.

 

18. view the output content of a specific file or URL without checkout SVN cat http :// Full file path
Example:
SVN cat http: // 192.168.0.3/test/readme.txt

 

Supplement:

If you wantChange the svn user name and passwordFor Linux:

 

1. Temporary Switch

 

Add the -- username and -- password options to all commands.

 

For example, SVN up -- username zhangsan -- password 123456

 

2. Permanent Switch

 

Go ~ /. Subversion directory, command line: Cd ~ /. Subversion

 

Back up data before deletion, Just in case: Command Line: CP-R ~ /. Subversion/auth // home/Luke/

 

Rm-rf auth/delete non-empty directory, not to recycle bin.

Delete directory ~ All files under/. Subversion/auth. During the next SVN operation, you will be prompted to re-enter the user name and password. If you want to use it, you can. The system will record it by default.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.