Simple SVN Course

Source: Internet
Author: User
Tags svn update tortoisesvn

Simple SVN Course

1. Version Control Introduction
1.1. What is version control?



The version control system is used to save each revision of the document used for application development ).
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

  • 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;

  • Support multiple developers to work for the same code in a controllable manner;

  • 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 between 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.
Installation Package in Windows:

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, use a third-party graphic 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 through the Eclipse plug-in, subclipse (

Http://subclipse.tigris.org/update_1.2.x/


Online installation:
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 up
SVN ci-M "Modify 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_name
SVN commit-M "XXXX"
Or:
Svn cp path/file_name newpath/new_file_name
SVN 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 "Create a branch for implementing the radio tag"

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.

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.