SVN commonly used command collection (notes)

1. Download the code on the server to the local
cd <directory where the code needs to be downloaded>
svn co svn://192.168.1.2/ directory or file--username username--password password

svn checkout = svn co
注:如果不带--password 参数传输密码的话,会提示输入密码,建议不要用明文的--password 选项。

2. Synchronize the locally modified data to the server
svn ci -m "submit remarks information text"
svn commit = svn ci

3. Sync the new data on the server to the local
svn update
or
svn up

4. View the basic information of the version warehouse
svn info svn://192.168.1.2
svn info

5. View log
① View log
svn log svn://192.168.1.2 of the version warehouse
② View all log
svn log test.php of the specified file
③ View log
svn log -r 100 of the specified version number

6. Add the file or directory to version control.
Submission failed. The file will not be processed by svn. At this time, you must first add the file or directory to version control.
svn add file name (directory name)

7. View the differences of files
svn diff //View the differences of all files
svn diff filename //View only the differences of a certain file

8. View the server file content
svn cat svn://192.168.1.2/file name

9. Cancel the modification (not yet submitted)
① Cancel the modification of the local file
svn revert file name
svn revert -r directory name


②Undo all local modifications under the directory svn revert --recursive directory name

10. Delete files
svn delete svn://192.168.1.1/ directory or file -m "delete the information text of remarks"
svn delete file name
svn ci -m "delete test files"

11. Restore the file from version 7 to version 2
svn merge -r 7:2 filename

12. View changes
① View all changes in the current workspace
svn diff
② View the difference between the current workspace test.php file and the latest version
svn diff test.php
③ View the difference between the current workspace and the bin directory in version 301
svn diff -r 301 bin

13. To view the file list, you can specify -r to view, and view the file list of the specified version number
svn ls
svn ls -r 100

14. Show who changed each line of the file at the end (a bug, often used to check who changed this code)
svn blame test.php

15. View the file content of the specified version, without the version number, you can view the latest version of
svn cat test.php -r 2

16. Cleanup
svn cleanup

17. Create a folder, and add it to version control, but ignore all file contents in the folder
svn mkdir spool
svn propset svn:ignore'*' spool
svn ci -m "Add the directory spool, ignore the spool folder content"

18. Switch the current directory to the specified branch and update the new version on the server. We often use this command to switch the current code to the new branch
svn switch svn://192.168.0.1/test/python

19. Redirect warehouse address to new address
svn switch --relocate original svn address new svn address

20. Create a branch, create a branch from the trunk and save it to branch
svn cp -m "Description Content" svn://192.168.1.2/test/trunk svn://192.168.1.2/test/branch

21. Merge the latest code on the trunk to the branch
cd test/branch
svn merge svn://192.168.1.2/test/trunk

22. Merge the branch to the trunk
cd test/trunk
svn merge --reintegrate svn://192.168.1.2/test/branch

23. Delete the branch
svn rm svn://192.168.1.2/test/branch

note:

1. Different users modify different files and update directly
2. Different users modify different lines of the same file, and the submission will fail. You must first svn update,> then resubmit

To remove a directory out of svn version control, you only need to delete the hidden .svn files in the directory.

24. Export (the purpose is to make the exported file directory without svn related files, nor under the control of the client, and cannot be updated.commit operation)
svn export [-r version number] svn://192.168.1.2 [Full path of the local directory] --username username --password password

If a revision is specified, the corresponding version will be exported and exported to the specified location.
If no revision is specified, the latest version will be exported and exported to the specified location.
If the full path of the local directory is omitted, the last part of the URL will be As the name of the local directory

The difference between checkout and export:

The checkout folder is controlled by the client. Any addition, deletion, and modification of files or folders will be recognized by the SVN client. Update and commit operations can be performed on it. It contains hidden .svn folders. This The folder contains the control information of the SVN client

The exported folder does not contain the hidden .svn folder, so it is not controlled by the client and cannot be updated or committed.

25.
Lock /unlock svn lock -m "lock remarks message text" [–force] file name
svn unlock file name

26. View svn help
svn help

27. View the help information of the specified command
svn help command
For example:
svn help ci
svn help co
svn help merge

Guess you like

Origin blog.csdn.net/weixin_44901564/article/details/108384630