Common SVN commands

Source: Internet
Author: User
Tags svn update tortoisesvn
ArticleDirectory
    • 1.1. What is version control?
    • 1.2. Benefits of using Version Control
    • 1.3. Common Version Control Systems
    • 3.1. Subversion Installation
    • 3.2. Server Side
    • 3.3. Client
    • 4.1. file lock
    • 4.2. Version library creation policy
    • 4.3. Use tags and branches

Simple SVN Course

Branches and tags introduction of SVN

Others

Link: http://www.iteye.com/topic/424804

Simple SVN Course

 

 

1. Version Control Introduction

 

 

1.1. What is version control?

 

The version control system is used to save and write applications.ProgramEach revision of the document (revision ).

Version Control is also called Revision Control System (RCS ).

Glossary:

    • Revision: it can be considered as a snapshot of a file stored in its lifecycle. Each snapshot corresponds to a time interval.
    • Version Library (repository): stores the version Database
    • Local working copy: local copy of the Revision
    • Check in: the local copy is submitted to the server version library.
    • Check out: extracts the version from the server version library to make a local copy.
    • Version Number Source: There are two policies: file-based counting and warehouse-based counting. Subversion uses the latter
    • Tags: adds a name for the version to facilitate detection
    • Branches
    • Merge: Merge the revision of a branch into a new version.
    • Locking: A revision lock.
    • Conflict: An error mechanism that prevents confusion of revisions During Concurrent Version Control

 

1.2. Benefits of using Version Control

 

Benefits for both teams and individuals:

    • Provides the team with a rollback button for all project documents;
    • Multiple developers can use the sameCodeWork;
    • The version control system saves the previous changes to the document, so that you can easily find who, when, and what modified the document;
    • Support multiple versions at the same time on the main line of the document;
    • You can query the status of each document in a project at a certain time point, which can be used to study production efficiency or re-release previous software releases.

 

1.3. Common Version Control Systems

 

    • VSS: Visual source save, Microsoft version controller software, http://msdn2.microsoft.com/zh-cn/vstudio/aa718670.aspx

    • CVS: Concurrent Versions System, open source free, http://www.nongnu.org/cvs/

    • Subversion, open source free, http://subversion.tigris.org/

    • Clearcase, IBM, http://www-306.ibm.com/software/awdtools/clearcase/

 

2. Subversion Introduction

 

Subversion is a new generation of version control tools and is gradually replacing CVs.

Resource:

    • Official Website: http://subversion.tigris.org/

    • Subversion Chinese site: http://www.subversion.org.cn/

    • Chinese manual: http://www.subversion.org.cn/svnbook/

    • Comparison of subversion and CVS: http://www.uml.org.cn/pzgl/200705251.asp

 

3. basic use of subversion

 

 

3.1. Subversion Installation

 

Subversion is a typical C/S mode application.

Windows Installation Package: http://subversion.tigris.org/files/documents/15/41687/svn-1.4.6-setup.exe

The installation process is very simple. The GUI is selected by default.

Run the svn command to check whether the installation is successful:

 

 
SVN -- version

 

The SVN command is the client of the subversion program.

The svnserver command can be used to start the svn server to build a simple SVN server environment.

See http://www.easymorse.com/bbs/viewthread.php? Tid = 95 & extra = Page % 3d1

 

3.2. Server Side

 

The following describes how to set up a simple server environment. Apache is generally used for HTTP access.

 

3.2.1. Create a version Library

 

Create a server version database, which is equivalent to a database example created by a DBMS.

Command line:

 

 
Svnadmin create file_path/repo_name

 

 

3.2.2. Start the server

 

 

Svnserve.exe-d-r file_path

 

    • -D background execution
    • -R version library root directory

URL for accessing this version Library: SVN // localhost/repo_name

 

3.3. Client

 

 

3.3.1. Initial Import)

 

Import through command line:

 

 
SVN import-M "init import" http: // 10.0.0.6/SVN/teaching/

 

This command can import files in the current path to the version library.

 

3.3.2. Check (checkout)

 

Check in through command line:

 

 
SVN Co http://hibernate3demo.googlecode.com/svn/tags/helloworld_r1

 

Or:

 

 
SVN checkout http://hibernate3demo.googlecode.com/svn/tags/helloworld_r1

 

Or: Check out through a third-party graphics tool, such as tortoisesvn (http://tortoisesvn.tigris.org /)

Download the latest version of the svn server to a local copy.

 

3.3.3. Update)

 

Command line:

 

 
SVN update

 

Or

 

 
SVN up

 

Or use tortoisesvn

Or install: http://subclipse.tigris.org online through Eclipse plug-ins, subclipse (http://subclipse.tigris.org/update_1.2.x//)

Update the local work copy with the latest version of the svn server.

When many people work together:

    • Updates should be performed frequently, and problems should be exposed as early as possible to facilitate handling.
    • Update the code before submitting the code. Otherwise, a version conflict may occur.

 

3.3.4. Add)

 

Command line:

 

 
SVN add file_path

 

Or use tortoisesvn and Eclipse plug-ins.

Tell the svn server to add directories and/or files to the server. This operation is similar to SQL insert, but it does not really operate until commit.

 

3.3.5. Submit changes

 

It is equivalent to a general concept: checkin ).

Command line:

 

 
SVN commit

 

Or:

 

 
SVN Ci

 

Or use tortoisesvn and Eclipse plug-ins.

Submit all modifications to the local work copy, which are atomic.

Requirement: Generally, the reason for the modification must be specified.

 

 
SVN ci-M "Modify bug #224"

 

Requirement: update before submission

 

 
SVN upsvn ci-M "modifying bug #224"

 

 

3.3.6. Restore changes

 

The corresponding commit operation must have a rollback operation.

 

 
SVN revert

 

Or use tortoisesvn and Eclipse plug-ins.

This operation is very useful to developers and can be "restored with one click" After many code changes are made ".

 

3.3.7. "Restore" submitted changes

 

Revert is only applicable when not submitted.

If a problem is found, roll back to the previous revision.

First, you must:

 

 
SVN up

 

Update the local copy to the latest status.

Then:

 

 
SVN log your_file_path

 

View the file log. The description entered during submission will be used in this case.

View the differences between the two revisions:

 

 
SVN diff-r old version number: New Version Number your_file_path

 

Or use tortoisesvn and Eclipse plug-ins.

After deciding which old version number to use, overwrite the new version number file with the old version number file.

 

SVN merge-r new Revision No.: Old Revision No. your_file_path

 

You also need:

 

 
SVN commit-M "restoring to a certain revision (a certain revision is voided )"

 

Or use tortoisesvn and Eclipse plug-ins.

This restoration is called. Instead of replacing the old version number, it overwrites the new file.

 

3.3.8. Copy files and directories

 

Command line:

 

 
SVN copy path/file_name newpath/new_file_namesvn commit-M "XXXX"

 

Or:

 

 
Svn cp path/file_name newpath/new_file_namesvn commit-M "XXXX"

 

Or use Windows Resource Manager/Unix CP command

Or use tortoisesvn and Eclipse plug-ins.

SVN copy is an important tool. It is used to implement versions, branches, labels, and other concepts.

SVN copy is a cheap copy.

 

3.3.9. rename a directory/File

 

Command line:

 

 
SVN move file_name new_file_name

 

Or:

 

 
Svn mv file_name new_file_name

 

 

3.3.10. Handle merge conflicts

 

SVN does not lock files by default.

If different users edit different parts of the same file, the file is automatically merged upon submission.

If different users edit the same part of the same file, the submitter reports a merge conflict.

Solution (manual arbitration ):

    • Discard changes;
    • Stick to your changes, find the. Mine file name, restore to the original file name, and then execute:
      SVN resolved file_name

 

3.3.11. delete an object

 

Delete a local copy of work.

Command line:

 

 
SVN Delete file_path

 

Or:

 

 
SVN del file_path
4. Subversion advanced content

 

4.1. file lock

 

It is generally used for binary content because it cannot be merged.

If a file is locked, the local copy (after update) of other users will be read-only.

After the user submits the file, the local copy (after update) of other users can be written.

Other users can "unlock" and then perform write operations.

Advanced configuration allows you to configure the "crowning" permission so that no one can "crowning ".

 

4.2. Version library creation policy

 

A single version library saves a project.

A single version library saves multiple projects.

Multiple version libraries.

 

4.3. Use tags and branches

 

In SVN, both labels and branches are derived from the Copy command.

Three Common directories:

    • Trunk: Trunk
    • Branches: Branch
    • Tags: Tag

Release Branch:

 

 
Svn cp-M "creating branch for implementing radio labels" https://easymorse-simpletag.googlecode.com/svn/branches/simpletag_select_1 https://easymorse-simpletag.googlecode.com/svn/branches/simpletag_select_2

 

Switch Branch:

 

SVN switch https://easymorse-simpletag.googlecode.com/svn/branches/simpletag_select_2

 

Two steps are required to merge branches:

Merge operations

 

 
SVN merge-r 33: Head https://easymorse-simpletag.googlecode.com/svn/branches/simpletag_select_2

 

Or:

 

 
SVN merge https://easymorse-simpletag.googlecode.com/svn/trunk/simpletag@HEAD https://easymorse-simpletag.googlecode.com/svn/branches/simpletag_select_1@HEAD

 

Submit.

 

5. unmentioned content

 

    • SVN backup
    • Subversion attributes
    • Configuration and use integrated with Apache

 

Link: http://www.iteye.com/topic/28013

SVN has been used for a long time as CVS, and I have never carefully read the documentation. I used it today to read the svn book documentation. 

Requirement 1:
One customer wants to customize the product, but we do not want to modify the trunk code in the original SVN.

Method:
Use SVN to create a new branches, and use this Branche as a new starting point for development.

Java code
    1. SVN copy SVN:// Server/trunk SVN: // server/branches/EP-M "init EP"

Tip:
If you have no branches directory in SVN, you can use

Java code
    1. SVN mkdir branches


New directory

Requirement 2:
Product development has been basically completed and passed strict tests. At this time, we want to release our 1.0 version to our customers.

Java code
    1. SVN copy SVN:// Server/trunk SVN: // server/tags/release-1.0-M "1.0 released"

What is the difference between this and branches?
Yes, branches and tags are the same. They are all directories, but we will not modify the release-1.0 tag and will not submit it any more. If yes, it will be branches.

Requirement 3:
One day, a fatal bug was suddenly found in the core of trunk, so all branches must be the same. What should I do?

Java code
    1. Svn-R148:149Merge SVN:// Server/trunk Branches/EP


148 and 149 are the version numbers modified twice.

What about others? View document

 

 

Original address: http://blog.chinaunix.net/space.php? Uid = 22976768 & Do = Blog & id = 1640924

    Tortoisesvn in WindowsIs a resource manager plug-in that overwrites the icon to indicate the File status. Almost all commands are supported by graphical interfaces,It is easy to use. This article mainly describes how to use Svn in Linux, because most of the operations in Linux are performed through command lines, so you must master Common commands of Svn in Linux. Of course, there are also Linux X programs that imitate tortoisesvn in Linux, such as rabbitvcs. The imitation is very high, but it is easy to slow down X, so it is not recommended. (If the file is submitted for the first time, "SVN: '.' is not a working copy" may occur, that is, the current directory is not a working copy. In this case, import is required: Eg: SVN import. url) 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
Abbreviation: 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 "logmessage" [-N] [-- no-unlock] path (if you choose 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 specific version.
SVN update-r m path
For example:
If there is no directory after SVN update, all files in the current directory and sub-directories 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 State of the files and subdirectories under the directory. The normal state is not displayed)
【? : Not under SVN control; M: The content is modified. ; C: conflict occurs. A: It is scheduled to be added to the version library. K: it is locked. m is usually in many States.
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 be executed without a network, because SVN is locally deployed. SVN retains the original copy of the local version.
Abbreviation: SVN St
7. delete an object
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 delete SVN test. php and then SVN ci-M 'delete test file'. 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 (compare the modified file with the basic version)
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
--------------------------
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 to wait 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 change), but the working copy is still mapped to the same directory in the same repository.
This command updates 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: subcommands do not follow the syntax to resolve conflicts or remove conflicting tags. They only remove conflicting tags.
Related 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)

End

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.