Use of svn commands in linux

Source: Internet
Author: User
Tags svn update what svn perl script

Use of svn commands in linux

Recently, svn is often used for code management. These commands can't be remembered, so I have to check them online. I finally found a svn command in linux, the svn commands in linux are summarized as follows.

1. checkout the file to the local directory.

Svn checkout path (path is the directory on the server)

Example: svn checkout svn: // 192.168.1.1/pro/domain

If you have already remembered the path, you can simply enter it as svn co.

2. Add new files to the version Library

Svn add file

Example: svn add./test. php (add test. php)

Svn add./*. php (add all php files in the current directory)

3. Submit the modified file to the version library.

Svn commit-m "Description log" [-N] [-- no-unlock] PATH (if the lock is selected, use the-no-unlock switch)

For example, svn commit-m "adds a test file" test. php

Submit the current directory and all the files in the subdirectories of the current directory. The file can be abbreviated as svn ci.

4. Lock/unlock

Svn lock-m "Description log" [-- force] PATH

Example: svn lock-m "lock test file" test. php

Unlock command: svn unlock PATH

5. Update to a specific version.

Svn update-r m path

For example:

Svn update if there is no directory at the end, all files in the current directory and subdirectory are updated to the latest version by default.

Svn update-r 200 test. php (restore the file test. php In the version library to version 200)

Svn update test. php (updated for version library synchronization. If an expiration prompt is prompted during submission, it is because of a conflict. You need to update the file, modify the file, clear svn resolved, and then submit commit)

Abbreviation: svn up

6. view the file or directory status

(1) svn status path (the status of all files in the current directory and sub-directory. The normal status is not displayed)

Specific Status display instructions:

【? : Not under svn control; M: The content is modified; C: A conflict occurs; A: It is scheduled to be added to the version Library; K: it is locked]

(2) svn status-v path (displays the status of files and subdirectories)

The first column remains the same, the second column displays the working version number, and the third and fourth columns show the last modified version number and modifier.

Note: svn status, svn diff, and svn revert commands can also be executed without a network, because svn is local. svn retains the original copy of the local version.

Abbreviation: svn st

7. delete an object

Svn delete path-m "log description"

For example: svn delete svn: // 192.168.1.1/pro/domain/test. php-m "delete test file"

Or directly delete svn test. php and then svn ci-m' delete the test. phpfile '. We recommend that you use this

Abbreviation: svn (del, remove, rm)

8. View logs

Svn log path

For example, svn log test. php displays all the modification records of this file and changes to its version number.

9. View File details

Svn info path

Example: svn info test. php

10. Differences

Svn diff path

Example: svn diff test. php

Svn diff-r m: n path (differences between version m and version n)

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 test. php (merge the differences between version 200 and version 205 to the current file, but there are usually conflicts. You need to handle them)

12. SVN help

Svn help

Svn help ci

The above are common commands. Below are a few that are not commonly used!

13. List of files and directories in the version Library

Svn list path

Displays all files and directories in the path directory that belong to the version library.

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 version control directory.

1. Each directory specified by the working copy PATH will be created on the local end and added to the new scheduling for the next submission.

2. Each directory specified with a URL is created by submitting it to the repository immediately.

In both cases, all the intermediate directories must exist in advance.

15. Restore local modification

Svn revert: restore the original unchanged working copy file (recover most local modifications ). Revert:

Usage: revert PATH...

Note: The sub-commands do not access the network and will release the conflict. But it won't be restored.

Deleted directory

16. code library URL change

Svn switch (sw): update the working copy to different URLs.

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 similar to "svn update", and the files on the server will be merged with local files. This is a method that maps a work copy to a branch or tag in the same repository.

2. Rewrite the URL metadata of the working copy to reflect the changes on the simple URL. When the root URL of the Repository changes (for example, the solution name or host name changes ), however, when the working copy is still mapped to the same directory in the same warehouse, use this command to update the correspondence between the working copy and the warehouse.

My example: svn switch -- relocate http: // 59.41.99.254/mytt http://www.mysvn.com/mytt

17. Conflict Resolution

Svn resolved: remove the "Conflict" Status of the directory or file of the working copy.

Usage: resolved PATH...

Note: subcommands do not follow the syntax to resolve conflicts or remove conflicting tags. They only remove conflicting files and then allow the PATH to be submitted again.

18. output the content of the specified file or URL

Svn cat target [@ version]… If a version is specified, search for it 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 result can be submitted)

19. Search for all the remaining log files in the working copy and delete the locks in the process.

When the Subversion changes your work copy (or. svn), it will be as careful as possible, before modifying anything, it writes the intent to the log file, then executes the command in the log file, and then deletes the log file, this is similar to the file system architecture of the ledger. If the Subversion operation is interrupted (for example, the process is killed and the machine is dead), the log file is saved on the hard disk and re-executed by the log file, subversion can complete the previous operation, and your copy of work can return to the consistent state.

This is what svn cleanup does: it searches for all the remaining log files in the work copy and deletes the locks in the process.

If the Subversion tells you that some of the work copies are "locked", you need to run this command. Similarly, svn status displays locked items using L:

$ Svn status
L somedir
M somedir/foo. c

$ Svn cleanup
$ Svn status
M somedir/foo. c

20. Copy a user's unversioned directory tree to the version library.

The svn import command is the fastest way to copy the user's unversioned directory tree to the version library. If necessary, it also needs to create some intermediary files.

$ Svnadmin create/usr/local/svn/newrepos
$ Svn import mytree/usr/local/svn/newrepos/some/project Adding mytree/foo. c Adding mytree/bar. c Adding mytree/subdir/quux. h Committed revision 1.

In the previous example, the directory mytree will be copied to some/project of the version Library:

$ Svn list/usr/local/svn/newrepos/some/project bar. c foo. c subdir/

Note: After the import, the original directory tree is not converted to a work copy. To start the operation, you still need to run svn checkout to export a work copy.

Appendix: Email notification for SVN

You can use the Subversion Hook script to add the mail list function to SVN.

After compiling and installing the Subversion, there is a comm-email.pl Perl script under the source tools, there is a hooks directory under your file directory, go to the hooks directory and rename the post-commit.tmpl to post-commit and give it executable permissions.

Change the post-commit script to add the path to the comm-email.pl script, otherwise SVN cannot find the comm-email.pl

REPOS = "$1"
REV = "$2"
/Usr/local/svn/resp/commit-email.pl "$ REPOS" "$ REV" email@address1.com email@address2.com
# Log-commit.py -- repository "$ REPOS" -- revision "$ REV"

Replace the email@address1.com email@address2.com address in the code above with your own mail address and that's OK.

The last line is used to record logs. I did not need this function, so I commented out it.

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.