Common SVN commands

Source: Internet
Author: User
Tags svn update what svn

Common SVN commands

SVN (Subversion) is a free and open source project source code version control tool. Currently, most open-source software and enterprise code management use SVN as the code version management software.

Subversion stores files in the central version library, which is similar to a common file server. The difference is that it can record every file and directory modification, so that you can recover the data to the previous version when you need rollback, and view the data change details.

Subversion configuration instances in Linux

CentOS 6.2 SVN setup (YUM installation)

Build an SVN server using Apache + SVN

Set up and use the SVN server in Windows + reset the password on the client

Install SVN in Ubuntu Server 12.04 and migrate Virtual SVN data

Build svn service and migration method on Ubuntu Server

Build SVN server with online storage

I. Common SVN commands

1. checkout the file to the local directory.
Svn checkout path (path is the directory on the server)
Abbreviation: svn co

2. Add new files to the version Library
Svn add file

3. Submit the modified file to the version library.
Svn commit-m "LogMessage" [-N] [-- no-unlock] PATH (if the lock is selected, use the-no-unlock switch)
Abbreviation: svn ci

4. Lock/unlock
Svn lock-m "LockMessage" [-- force] PATH
Svn unlock PATH

5. Update to a specific version.
Svn update-r m path
Abbreviation: svn up

6. view the file or directory status
1) svn status path (the State of the files and subdirectories under the directory. The normal state is not displayed)
2) svn status-v path (displays the status of files and subdirectories)
Abbreviation: svn st

7. delete an object
Svn delete path-m "delete test fle"
Abbreviation: svn (del, remove, rm)

8. View logs
Svn log path

9. View File details
Svn info path

10. Differences
Svn diff path (compare the modified file with the basic version)
Svn diff-r m: n path (differences between version m and version n)
Abbreviation: svn di

11. Merge the differences between the two versions into the current file.
Svn merge-r m: n path

12. SVN help
Svn help
Svn help ci

 

 


Ii. Uncommon SVN commands
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. Short for: svn ls

14. Create a new directory under Version Control
Svn mkdir: Create a new directory under version control.
Usage:
1. mkdir PATH...
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. Create a version control directory.
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 ).
Usage: revert PATH... note: sub-commands do not access the network and will remove the conflict. However, it does not restore the deleted directory.

16. code library URL change
Svn switch (sw): update the working copy to different URLs.
Usage:
1. switch URL [PATH]
Update your work copy and map it to a new URL. The behavior is similar to "svn update", and the files on the server are merged with local files. This is a method that maps a work copy to a branch or tag in the same repository.
2. switch -- relocate from to [PATH...]
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.

17. Conflict Resolution
Svn resolved: the "Conflict" Status of directories or files that remove working copies.
Usage: resolved PATH... note: the subscriber command does not resolve conflicts or remove the conflict mark according to the syntax. It only removes conflicting files and allows the PATH to be submitted again.

18. output the content of the specified file or URL.
If the svn cat target [@ version]... is specified, it 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 that the output result can be submitted)
 

 


Iii. Other SVN commands

Although it is not as common as the commands previously discussed in this chapter, you sometimes need these commands.

Svn cleanup
When Subversion modifies your working copy (or any information in. svn), it tries to be as secure as possible. Before changing a working copy, Subversion writes its intent to a log file. Next, it executes the commands in the log file to apply the required modifications. Finally, Subversion deletes the log file. In architecture, this is similar to a log file system (journaled filesystem. If a Subversion operation is interrupted (for example, the process is killed or the machine is down), the log file is still on the hard disk. Re-execute the log file, Subversion can complete the previous operations, so that your work is back to a reliable state.

The following is what svn cleanup does: it searches for your work copy and executes all legacy logs to delete the lock during this process. If the Subversion tells you that part of your work copy is "locked", you should execute this command. In addition, svn status displays L before the locked item.

$ Svn status
L somedir
M somedir/foo. c

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

Svn import
Using svn import is a quick way to copy a non-versionized file tree to a database. It needs to create a temporary directory.

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

Committed revision 1.

In the preceding example, the contents of the mytree directory under some/project directory are copied to the database.

$ Svn list file: // usr/local/svn/newrepos/some/project
Bar. c
Foo. c
Subdir/

Note that after the import is complete, the original tree is not converted into a working copy. To get started, you still need a new working copy of the svn checkout tree.

For more details, please continue to read the highlights on the next page:

  • 1
  • 2
  • Next Page

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.