SVN (Subversion) Concise Practical course

Source: Internet
Author: User
Tags commit rollback svn svn update time interval version control system tortoisesvn

1. Introduction to Version control

1.1. What is version control
Version control systems are used to save individual revisions (revision) of documents that were written to develop the application.

Versioning is also known as the Revision control System (RCS).

Noun Explanation:

Revision (revision): You can think of a file in its lifecycle each saved snapshot, each snapshot and a time interval corresponds.
Version library (Repository): Database with revisions
Local working copy (working copy): Local copy of Revision
Version check-in (check in): local copy commits to the server's version library
Check out: Remove the revision from the server's version library to become a local copy
Source of version number: There are two strategies, file-based count and warehouse based count, Subversion uses the latter
tags (tags): Add a name for the version, easy to check out
Branch (Branches): Revised version of the branch, can be modified in parallel, mutual interference
Merging (merging): Merging the revisions of a branch into a new revision
Lock (Locking): for revision yoke
Conflict (CONFLICT): Error mechanism to prevent revision confusion when concurrent version control

1.2. The benefits of using version control
Good for both the team and the individual:

Provides a fallback button for all project documents for the team;
Enables multiple developers to work in a controlled manner for the same code;
The version control system preserves the changes in the document in the past, making it easy to find out who, when, and what changed the document;
Supports multiple versions at the same time on the main line of the document;
Supports querying the status of project documents at a certain point in time, can be used to study productivity, and can be used for redistribution of previous software distributions.

1.3. Common version control system
Vss:visual source Save, Microsoft's 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 Company, http://www-306.ibm.com/software/awdtools/clearcase/

2. Introduction to Subversion
Subversion is a new generation of versioning tools that is gradually replacing CVS.

Resources:

Official website: http://subversion.tigris.org/

Subversion Chinese Station: http://www.subversion.org.cn/

Chinese Handbook: http://www.subversion.org.cn/svnbook/

Subversion vs. CVS: http://www.uml.org.cn/pzgl/200705251.asp

3. Subversion Basic use

3.1. Subversion installation
Subversion is a typical C/S mode application.

installation packages in Windows environment: Http://subversion.tigris.org/files/documents/15/41687/svn-1.4.6-setup.exe

The installation process is simple, graphical interface, the default selection can be.

Enter SVN command to see if the installation was successful:

SVN--version
SVN command is a client of the Subversion program

The Svnserver command can 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 is the practice of building a simple server-side environment, officially with Apache through HTTP access.

3.2.1. Create a version library
Create a server-side version library, equivalent to a DBMS to create a database sample.

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:svn//localhost/repo_name access to this version library

3.3. Client

3.3.1. Initial imports (Import)
Import by command line:

SVN import-m "init import" http://10.0.0.6/svn/teaching/
This command imports files from the current path into the version library.

3.3.2. Check out (checkout)
Check in from the 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 of a third-party graphics tool, such as TORTOISESVN (http://tortoisesvn.tigris.org/)

Download the latest revision of the SVN server to a local working copy locally.

3.3.3. Keep updating (update)
Command line:

SVN update
Or

SVN up
or through TORTOISESVN.

or through the Eclipse plug-in, Subclipse (http://subclipse.tigris.org/), install online: http://subclipse.tigris.org/update_1.2.x/

Update your local working copy with the latest revision of the SVN server.

When many people cooperate:

Update frequently to do, as far as possible to expose the problem early, easy to handle.
Update the code before submitting it, or it can easily cause version conflicts.

3.3.4. Adding (ADD)
Command line:

SVN add File_path
or through the Tortoisesvn,eclipse plugin.

Tell the SVN server to add directories and/or files to the server, this operation is similar to SQL INSERT, but there is no real operation until commit.

3.3.5. Submit Changes
Equivalent to a common concept: check in (checkin).

Command line:

SVN commit
Or:

SVN ci
or through the Tortoisesvn,eclipse plugin.

Commits all changes to the local working copy, and is atomic in nature.

Requirements: General to indicate the reasons for the change

SVN ci-m "Modify Bug #224"
Requirements: Update prior to submission

SVN up
SVN ci-m "Modify Bug #224"

3.3.6. Restore changes
corresponding commit (commit), there is a similar rollback (rollback) operation.

svn revert
or through the Tortoisesvn,eclipse plugin.

This is useful for developers and can be "one-click Recovery" After a lot of code is changed.

3.3.7. "Restore" submitted changes
Revert is only suitable for uncommitted situations.

If you have already committed a problem, you will fall back to the previous revision.

First you need to:

SVN up
Let the local working copy update to the latest status.

And then:

SVN log Your_file_path
Look at the file log, which is useful when you fill out the instructions at the time of submission.

View the differences between two revisions:

SVN diff-r Old revision ordinal: New revision serial number Your_file_path
or through the Tortoisesvn,eclipse plugin.

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

SVN merge-r New revision serial number: Old revision serial number Your_file_path
also requires:

SVN commit-m "revert to a revision (void for a revision)"
or through the Tortoisesvn,eclipse plugin.

This restore is called, instead of replacing the old version number, overwriting the old file with 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: The CP command/unix using Windows Resource Manager

or through the Tortoisesvn,eclipse plugin.

SVN copy, is a very important tool, version branch and label concepts are implemented through it.

SVN copy, is a cheap copy.

3.3.9. Renaming a directory/file
Command line:

SVN move file_name new_file_name
Or:

SVN mv file_name new_file_name

3.3.10. Handling merge conflicts
SVN does not lock files by default.

If different people edit different parts of the same file, the commit is merged automatically.

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

Workaround (Manual arbitration):

Discard changes;
Stick with your changes, find the. mine file name, revert to the original filename, and then execute:
SVN resolved file_name

3.3.11. deleting files
Deletes a local working copy.

Command line:

SVN delete File_path
Or:

SVN del File_path

4. Subversion Advanced Content

4.1. File lock
Typically used for binary content because it cannot be merged.

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

When the user submits, the local working copy of the other user (updated) is not available for write operations.

Other users can "pry the lock" and write.

Advanced configuration can be configured to "pry lock" permissions so that not everyone can "pry locks."

4.2. Version Library creation Policy
Single version library to save a project.

A single version library holds multiple projects.

Multiple version libraries.

4.3. Using labels and branches
Both the label and the branch in SVN originate from the Copy command.

3 Established Directories:

Trunk: Trunk
Branches: Branch
Tags: tags
Publish Branch:

SVN cp-m "Create a branch to implement the radio label" Https://easymorse-simpletag.googlecode.com/svn/branches/simpletag_select_1 https:// Easymorse-simpletag.googlecode.com/svn/branches/simpletag_select_2
To toggle a branch:

SVN switch https://easymorse-simpletag.googlecode.com/svn/branches/simpletag_select_2
Merging a branch requires two steps:

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.

Note:
TORTOISESVN daily Use guide-Chinese SVN technical data: http://www.svn8.com/SVNSY/20080318/360.html

Subversion Installation Guide: http://www.svn8.com/SVNSY/20090825/8889.html

TORTOISESVN Configuration server: http://www.svn8.com/SVNSY/20080318/358.html

This article from Csdn Blog, reproduced please indicate the source: http://blog.csdn.net/byxdaz/archive/2009/09/25/4593032.aspx

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.