Home >Operation and Maintenance >Linux Operation and Maintenance >Sharing of common svn commands under Linux
This article mainly shares with you common svn commands under Linux, hoping to help everyone.
1. Checkout the file to the local directory
svn checkout path (path is the directory on the server)
For example: svn checkout svn://192.168.1.1/pro/domain
Abbreviation :svn co
2. Add a new file to the repository
svn add file
For example: svn add test.php(add test.php)
svn add *.php( Add all php files in the current directory)
3. Submit the changed files to the repository
svn commit -m “LogMessage“ [-N] [--no-unlock] PATH (if selected To keep the lock, use the –no-unlock switch)
For example: svn commit -m “add test file for my test” test.php
Abbreviation: svn ci
4. Lock/ Unlock
svn lock -m “LockMessage“ [--force] PATH
For example: svn lock -m “lock test file“ test.php
svn unlock PATH
5. Update to A certain version
svn update -r m path
For example:
svn update If there is no directory after it, all files in the current directory and subdirectories will be updated to the latest version by default.
svn update -r 200 test.php (Restore the file test.php in the repository to version 200)
svn update test.php (Update, synchronize with the repository. If it prompts expiration when submitting , because of the conflict, you need to update and modify the file first, then clear svn resolved, and finally submit the commit)
Abbreviation: svn up
6. Check the file or directory status
1) svn status path (The status of files and subdirectories in the directory is not displayed in normal status)
[?: Not under the control of svn; M: The content is modified; C: Conflict occurs; A: Scheduled to be added to the repository; K: Locked 】
2) svn status -v path (display file and subdirectory status)
The first column remains the same, the second column displays the working version number, and the third and fourth columns display the last modified version number and modification people.
Note: The three commands svn status, svn diff and svn revert can also be executed without a network. The reason is that svn retains the original copy of the local version in the local .svn.
Abbreviation: svn st
7. Delete files
svn delete path -m “delete test fle”
For example: svn delete svn://192.168.1.1/pro/domain/test .php -m "delete test file"
Or directly svn delete test.php and then svn ci -m 'delete test file', it is recommended to use this
abbreviation: svn (del, remove, rm)
8. View the log
svn log path
For example: svn log test.php displays all modification records of this file and its version number changes
9. View file details
svn info path
For example: svn info test.php
10. Compare differences
svn diff path (compare the modified file with the basic version)
For example: svn diff test .php
svn diff -r m:n path (compare the differences between version m and version n)
For example: svn diff -r 200:201 test.php
Abbreviation: svn di
11. Merge the differences between the two versions into the current file
svn merge -r m:n path
For example: svn merge -r 200:205 test.php (merge the differences between versions 200 and 205 to the current file, but conflicts usually occur and need to be dealt with)
12. SVN help
svn help
svn help ci
13. Files and directories under the repository List
svn list path
Displays all files and directories belonging to the repository in the path directory
Abbreviation: svn ls
14. Create a new directory under version control
svn mkdir: Create a new directory under version control.
Usage: 1. mkdir PATH…
2. mkdir URL…
Create a directory for version control.
1. Each directory specified by the working copy PATH will be created locally, and a new
schedule will be added to wait for the next submission.
2. Each directory specified by URL will be created in the warehouse through immediate submission.
In both cases, all intermediate directories must exist beforehand.
15. Restore local modifications
svn revert: Restore the original unchanged working copy file (restore most local modifications). revert:
Usage: revert PATH…
Note: This subcommand will not access the network and will resolve the conflict. But it will not restore the
deleted directory
16. Code base URL change
svn switch (sw): Update the working copy to a different URL.
Usage:
1. switch URL [PATH]
2. switch –relocate FROM TO [PATH...]
1. Update your working copy and map it to a new URL. The behavior is very similar to "svn update", and it will also merge
files on the server with local files. This is a
method of mapping a working copy to a branch or tag in the same warehouse.
2. Rewrite the URL metadata of the working copy to reflect the simple changes in the URL. When the root URL of the warehouse changes
(such as the scheme name or host name changes), but the working copy is still mapped to the same directory in the same warehouse, use this command to update the corresponding relationship between the working copy and the warehouse.
17. Resolve conflicts
svn resolved: Remove the "conflict" status of the working copy's directory or file.
Usage: resolved PATH…
Note: This subcommand does not resolve conflicts or remove conflict markers according to the syntax; it only removes the conflicting
related files, and then allows PATH to be submitted again.
18. Output the contents of the specified file or URL.
svn cat target[@version]...If a version is specified, the search will start from the specified version.
svn cat -r PREV filename > filename (PREV is the previous version, you can also write a specific version number, so the output result can be submitted)
Related recommendations:
Detailed explanation of the steps to configure and use svn in phpstorm
Use phpstorm for svn submission
Compare two different svn branch directories in php Example analysis of the file
The above is the detailed content of Sharing of common svn commands under Linux. For more information, please follow other related articles on the PHP Chinese website!