Detailed explanation of SVN command usage

1. Check out
svn   co   http://path (full path of directory or file) [full path of local directory] 

 --username username --password password svn co svn://path (full path of directory or file) [full path of local directory] --username username --password password
svn checkout http://path (directory or file full path of local directory) [full path of local directory] --username username
svn checkout svn://path (full path of directory or file) [full path of local directory] --username username
Note: If the --password parameter is not used If you transmit a password, you will be prompted to enter the password. It is recommended not to use the --password option in clear text.
  There are two short lines before username and password, not one.
  If the full path of the local directory is not specified, it will be checked out to the current directory.
Example: svn co svn:// localhost/  testtools/home/testtools --username  wzhnsc svn co http:// localhost/test/testapp  --username  wzhnsc svn checkout svn:// localhost/  testtools/home/testtools - -username  wzhnsc svn checkout http://
 

 
 localhost/test/testapp  --username  wzhnsc

2 , export (export a clean directory tree without .svn folder )
svn export [-r version number] http://path (full path of directory or file) [local Directory full path] --username username
svn export [-r version number] svn://path (full path of directory or file) [local directory full path] --username username
svn export locally checked out (that is, with There is a .svn folder) directory full path The full path of the local directory to be exported
Note: The first form of exporting a clean working directory tree from the repository is to specify the URL.
   If the revision number is specified, the corresponding version will be exported.
   If If no revision is specified, the latest will be exported to the specified location.
If the full path to the local directory
   is omitted  , the last part of the URL will be used as the name of the local directory.   The second form is to specify the full path of the locally checked out directory to the full path of the local directory to be exported, and all local modifications will be preserved,    but not under version control (ie, new files that are not committed, because there is no new file in the .svn folder. related information records) are not copied. Example:



svn  export
  svn:// localhost  /testtools/home/testtools  --username wzhnsc
svn  export
  svn:// localhost/test/testapp  --username  wzhnsc
svn  export
  /home/ testapp  /home/testtools 3. Add a new file  svn add file name Note: To tell the SVN server to add a file, use svn commint -m upload the real one! 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 all php files for my test "*.php 4. Submit svn commit -m "Submit remark information text" [-N] [--no-unlock] File name svn ci -m "Submit remark information text" [- N] [--no-unlock] The file name must be accompanied by the -m parameter, the parameter can be empty, but must be written with -m Example:















svn commit -m  "commit all files under version control in the current directory" *  <-  note that * means all files
svn commit -m  "commit my test with test.php" test.php
svn commit -m  "commit My test uses test.php "  -N --no-unlock  test.php  <--  no-unlock switch to keep the lock
svn ci -m  "commit all files under version control in the current directory" *  <-  Note this * means 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 Use the –no - unlock switch

to lock latest version svn update -r




 
 200 test.cpp  <- Reverts  the file test.cpp in the repository to a revision (revision) 200
svn update  test.php  <-  The update is synchronized with the repository.
            When submitting, it prompts an expired conflict. You need to update the modified file first,
            then clear the svn resolved, and finally submit the commit.


6. Delete file
svn delete svn://path (full path of directory or file) -m "Delete remark information text" The
recommended operation is as follows:
svn delete  file name 
svn ci -m  "Delete remark information text"
Example:
svn delete svn : //localhost/testapp/test.php  -m  "delete test file test.php"
recommends the following operations:
svn delete  test.php 
svn ci -m  "delete test file test.php"

7. Lock/unlock 
svn lock - m "lock remark message text" [--force] filename 
svn unlock filename
example:
svn lock -m "Test.php file for letter lock test" test.php 
svn unlock  test.php

8. Compare the difference 
svn diff file name 
svn diff -r Correct version number m: Correct version number n
Example of file name:
svn diff  test.php <-  Compare the modified file with the base version
svn diff -r  200 : 201 test.php <-  Compare the difference between the revision number 200 and the revision number 201

9. View file or directory status
svn st directory path/name
svn status directory path/ Name <-  The status of files and subdirectories in the directory, the normal status does not display 
             [?: not under the control of svn; M: content modified; C: conflict;
              A: scheduled to be added to the repository; K: locked] 
svn -v directory path/name
svn status -v directory path/name <-  display file and subdirectory status
              [the first column remains the same, the second column shows the working version number,
               the third and fourth columns show the last modified version number and Modified by] 
Note: The three commands svn status, svn diff and svn revert can also be executed without a network,
  because svn keeps the original copy of the local version in the local .svn. 

10. View the log
svn log file name
example:
svn log  test.php <-  display all modification records of this file, and the change of the version number 

11. View the file details
svn info file name
example:
svn info  test.php

12, SVN help
svn help  <-  all function options
svn help ci  <- description of specific functions

13. View the list of files and directories under the 
repository svn list svn://path (full path of a directory or file)
svn ls svn:// Path (full path to a directory or file)
example:
svn list svn:// localhost/test
svn ls svn:// localhost/test  <-  display all files and directories belonging to the repository under the  svn://

localhost/test directory 14. Create a new directory under version control
svn mkdir Directory name
svn mkdir -m "Add directory remark text" http://Directory full path
Example:
svn mkdir  newdir
svn mkdir -m  "Making a new dir."  svn:// localhost/test/newdir 
Note: add After completing the subdirectory, be sure to go back to the root directory to update it, otherwise submitting a file in this directory will prompt "submission failure"
svn update
Note: If you manually create a new folder newsubdir in the directory that was checked out,
  use svn again After mkdir  newsubdir command, SVN will prompt:
  svn: try "svn add" or "svn add --non-recursive" instead?
  svn: Unable to create directory "hello": the file already exists
  At this point, use the following command to solve it:
  svn add --non-recursive  newsubdir
  After entering the newsubdir folder, use ls -a to view all the directories and files under it, you will find More: .svn directory and
  then use svn mkdir -m "add hello function module file" svn://localhost/test/newdir/newsubdir command,
  SVN prompt:
  svn: File already exists: filesystem '/data/svnroot/test/db', transaction '4541-1',
  path '/newdir/newsubdir '

15. Restore local modification 
svn revert [--recursive]
Note: this subcommand Will not access the network and resolve the conflict condition. But it doesn't restore deleted directories.
Example:
svn revert  foo.c  <-  discard changes to a file
svn revert --recursive  .  <- restore a whole directory of files, . for current directory 

16, update working copy to another URL 
svn switch http:// Directory full path Local directory full path
Example:
svn switch http:// localhost/test/456 .  <- (the branch of 123) The current directory branches to localhost/test/456

17. Resolve conflicts 
svn resolved [local directory full path]
Example:
$ svn update
C foo.c
Updated to revision 31.
If you get conflicts while updating, your working copy produces three new files:
$ ls
foo.c
foo.c.mine
foo.c.r30
foo.c.r31
When you have resolved the conflicts in foo.c and are ready to commit, run svn resolved to let your working copy know that you have done everything.
You can just delete the conflicting files and commit, but svn resolved not only deletes the conflicting files, but also fixes some of the log data recorded in the working copy management area, so we recommend you to use this command.

18. View the output of a specific file or URL without checkout. 
svn cat http://file full path
example:
svn cat http: //localhost/test/readme.txt

19. Create a new branch copy

svn copy  branchA branchB -m "make B branch" // copy a new branch branchB from branchA

20. Merge content to branch merge

svn merge  branchA branchB // Merge changes to branchA to branchB

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326319689&siteId=291194637