SVN use tutorial

Source: Internet
Author: User
Tags svn update version control system tortoisesvn

Learn SVN version control and recovery removal

First I looked at the version control introduced by others as follows:

1. Version Control Introduction

1.1. What is version control

The version control system is used to save each revision (revision) of the document that was written when the application was developed.

Version control is also known as revision control System (RCS).

Noun Explanation:
Revision (revision): Can be thought of as a file in its life cycle of each saved snapshots, each snapshot and a time interval corresponding.
The Repository (Repository): A database that holds a revised version
Local working copy: A local copy of the revision
Version of Check in: local copy submitted to server's repository
Check out: Remove the revision from the server's repository as a local copy
The source of the version number: There are two strategies, based on the file count and the warehouse-based count, which subversion uses
Tags: add a name to the version for easy checkout
Branch (Branches): Revision of the Branch, can be modified in parallel, non-interference
Merge (Merging): Merge a revision of a branch into a new revision
Lock (Locking): for revision shackles
Conflict (Conflict): An error mechanism to prevent revisions from being confused during concurrent version control

1.2. Benefits of using version control

Good for both teams and individuals:
? Provides a fallback button for all project documents for the team;
Support multiple developers working in a controlled manner for the same code;
The version control system preserves the various changes in the document in the past, making it easy to find who, when, and what modified the document;
Support for multiple versions at the same time on the main line of the document;
? supports querying the status of each document at a point in time, can be used to study productivity, and can also be used to re-release a previous software release.

1.3. Common version control system
?
Vss:visual Source Save, Microsoft Company 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. Subversion Introduction

Subversion is a new generation of version control tools that are gradually replacing CVS.

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

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

?
Chinese Manual: 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 package in Windows: Http://subversion.tigris.org/files/documents/15/41687/svn-1.4.6-setup.exe

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

Enter the SVN command to see if the installation was successful:


SVN--version

The SVN command is the client of the Subversion program.

Svnserver command to start the SVN server for 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 a simple server-side environment to build the practice, formally with Apache through HTTP access.

3.2.1. Creating a Repository

Create a server-side repository, equivalent to the DBMS creation database sample.

Command line:


Svnadmin Create File_path/repo_name

3.2.2. Starting the server


Svnserve.exe-d-R File_path
?-D Background execution
The root directory of the-R repository

Access to the repository's Url:svn//localhost/repo_name

3.3. Client

3.3.1. Initial imports (Import)

Import from the command line:


SVN import-m "init import" http://10.0.0.6/svn/teaching/

This command imports the files under the current path into the repository.

3.3.2. Checking out (checkout)

Check in with 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: Checked out by a third-party graphical 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. Keeping updates (update)

Command line:


SVN update

Or


SVN up

or through TORTOISESVN.

or via the Eclipse plugin, subclipse (http://subclipse.tigris.org/), installed online: http://subclipse.tigris.org/update_1.2.x/

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

When working with multiple people:
Update should be frequently done, as far as possible to let the problem early exposure, easy to deal with.
Before committing the code, it is easy to update, otherwise it will cause version conflicts.

3.3.4. Adding (ADD)

Command line:


SVN add File_path

or through the Tortoisesvn,eclipse plugin.

Inform the SVN server, 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. Submitting changes

Equivalent to the general 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: Generally note the reasons for the change


SVN ci-m "fix bug #224"

Requirements: To be updated before submitting


SVN up
SVN ci-m "fix bug #224"

3.3.6. Revert changes

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


svn revert

or through the Tortoisesvn,eclipse plugin.

This operation is very useful to developers, and can be "one-click Recovery" After a lot of code has been changed.

3.3.7. "Revert" a committed change

Revert is only suitable for uncommitted situations.

If you have already submitted, you find the problem and you want to fall back to the previous revision.

First, you need:


SVN up

Update the local working copy to the latest state.

And then:


SVN log Your_file_path

Look at the file log, which is where the information you fill out when you submit it comes in handy.

See the differences between the two revisions:


SVN diff-r Old revision sequence number: New revision number Your_file_path

or through the Tortoisesvn,eclipse plugin.

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


SVN merge-r New revision sequence Number: Old revision number Your_file_path

Also need to:


SVN commit-m "revert to a revision (void of a revision)"

or through the Tortoisesvn,eclipse plugin.

This restore is so-called, instead of replacing the old version number, overwrite the old file with the new one.

3.3.8. copying 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: Using the Windows Explorer/unix CP command

or through the Tortoisesvn,eclipse plugin.

The SVN copy is a very important tool, and the concepts of version branching and tagging are implemented through it.

The copy of SVN 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, they are automatically merged when they are submitted.

If a different person edits the same part of the same file, the submitter reports a merge conflict.

Workaround (manual quorum):
? waiver of changes;
Stick to your changes, find the. mine file name, revert to the original file name, and then execute: SVN resolved file_name


3.3.11. deleting files

Delete the local working copy.

Command line:


SVN delete File_path

Or:


SVN del File_path

4. Subversion Advanced Content

4.1. File lock

Generally used for binary content because it cannot be merged.

If a file is locked, the other user's local working copy (updated) will be read-only.

When the user submits, the local working copy of the other user (after the update) can be written.

Other users can "pry the lock" and then write.

Advanced Configuration You can configure the "pry lock" permission so that no one can "pry" the lock.

4.2. Repository Creation Policy

A single repository saves one project.

A single repository saves multiple projects.

Multiple versions of the repository.

4.3. Using labels and branches

In SVN, both the label and the branch originate from the Copy command.

3 Conventional Directories:
Trunk: Trunk
? Branches: Branch
? Tags: tags

To publish a branch:


SVN cp-m "Creating a branch for implementing radio tags" https://easymorse-simpletag.googlecode.com/svn/branches/simpletag_select_1 https:// Easymorse-simpletag.googlecode.com/svn/branches/simpletag_select_2

To switch branches:


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/[email protected] https:// Easymorse-simpletag.googlecode.com/svn/branches/[email protected]

Submit.

5. What's not mentioned
? SVN backup
? Subversion properties
? integration with Apache configuration and usage
?

SVN recovery and DELETE operations: Learning:


First, local deletion
Local Delete, refers to delete a file at the client, but there is no commit, use revert to undo the deletion.
Second, server delete
1. Submit the server via local delete
A) Update the previous version, but only for the less modified cases;
b) through show Log, find the deleted item, select, right click->revert changes from this revision;

2. Delete in Repo-browser
This deletion is very bad, so that you can not see the deleted items in the Repo-browser. The fact that the project was not actually deleted.
A) Local project also exists, right click->tortoisesvn->update to Revision, input is deleted Revision, OK, and then import up can.
b) The local project is gone.
Right-click->tortoisesvn->export ...,
Url of repository fill in the address of the project;
Export directory to fill in the path to be backed up;
Revision, the default is head Revision, but this is not available here. Since the project has been deleted, Head revision is only valid for existing projects, you'd better remember the previous version. If you really forget, look at it, until you find the version you need.
Click OK, if not the directory will prompt you to establish a, OK after the OK.

From the network, learn from each other, if there is infringement, please contact me immediately delete

SVN use tutorial

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.