Common SVN Command Tutorials

Source: Internet
Author: User
Tags diff svn svn update

Common SVN commands:

First you can view the Help information through SVN help/h.

Start work

Check out (checkout) server data to Local

If you've just entered a company, or a new team, and are immediately involved in a project, get the project code and start your project career. At this time you usually need to check out the project code:

SVN checkout/co [directory] project (local directory name, optional)///Check out version 3 SVN checkout/co–revision/r 3 [directory] project (local directory name, optional)

Then you can view the version information through SVN info.

Importing (Import) projects

Sometimes the project has not yet been created, you need to place the local directory in the SVN version warehouse:

SVN Import project (local directory name) [directory]

You can then confirm that you are already in the version warehouse through SVN list/ls.

Update

Every time you start coding, you'd better update the local working directory first:

CD Project SVN update/up//Update to version 3 SVN update/up–revision/r 3

This will allow you to work on the new project code base.

Modify

Perhaps you have written a new module that adds some new files that need to be included in the project's version control:

SVN add index.html list.html ...

You may find that a module is obsolete and is no longer used:

SVN delete/del/remove/rm hello.html

You may find that the name of a module is not very reasonable and needs to be renamed:

SVN move/mv main.css common.css

You may want to create a new larger module that requires a new directory:

SVN mkdir List

You may find that the module code that you want to write is similar to the old module, copying the entire code directly:

SVN copy/cp users/list.js list/list.js

Check

A busy day has passed, or a task has been completed, this time will generally be your work results, that is, code updates to the version warehouse.

It is customary to check the status of the modifications first:

SVN status/stat/st

See some SVN status bit information, confirm that the files have been modified, after the general will be their own code to review the changes, perhaps some people will be accustomed to directly svn way to view:

SVN Diff/di folder (local directory name, optional, default current directory)//view index.html current version and version 3 of the difference SVN diff/di–revision/r 3 index.html//view index.html version 3 and version 4 difference svn diff/di–revision/r 3:4 index.html

Generally this time, there is no special situation, directly into the "submit" phase, and then end a working day or work cycle, but there will be some special circumstances.

Cancel Modification

When your code review and you find some changes are not satisfactory, you may be able to cancel these changes:

svn revert index.html//rollback entire Directory svn revert. -r/--recursive

Branching operations

Create a branch

Create a branch

SVN copy/cp svn://xxx.com/repo/trunk svn://xxx.com/repo/branches/test-m ' make branch test '

Move the working directory to the branch

SVN switch/sw svn://xxx.com/repo/branches/test

Of course, you can also go to the trunk svn switch/sw svn://xxx.com/repo/trunk.

Label branches

To copy the latest publishing branch as a label:

SVN copy/cp svn://xxx.com/repo/branches/test Svn://xxx.com/repo/tags/test_tag

Merge a branch to the trunk

Find a branch version

CD branches/test (branch directory) SVN log–stop-on-copy

The last r11340 is the reversion when you create a branch, or you can:

CD trunk (skeleton directory) svn-q–stop-on-copy svn://xxx.com/repo/branches/test (branch URL)

This command queries all changes on the branch after the branch was created, and the bottom version number is the version number we are looking for.

Merge to Trunk

CD trunk (skeleton directory) SVN merge-r 11340 (branch version): Head svn://xxx.com/repo/branches/test (branch URL)

Two branch merges

Suppose 99 is derived from the old backbone, 100 dozen tag, said the new backbone.

Merging the latest code means that the new backbone is compared to the old trunk and added to 99. This 99 has its own new code, as well as the latest code on the line.

CD 99_branch svn merge svn://xxx.com/repo/tags/project_old_bl svn://xxx.com/repo/tags/project_new_bl svn ci-m ' merge Trunk '

But then, others to 100 to mention the code, so also need to 100 branches (that is, after playing the tag of 100, hit the tag before 100 is the backbone) merged into 99.

Consolidation method: Find the difference between the 100 branch and the new backbone and add it to 99. So 99 will have the latest full code.

CD 99_branch svn merge svn://xxx.com/repo/tags/project_new_bl svn:/xxx.com/repo/branches/100_branch svn ci-m ' Merge 100 Branch

Release

Label the current trunk, and the label will no longer change, but in fact the label and the branch are meant to be, you can continue to make changes on the label, but this is not recommended.

SVN copy/cp svn://xxx.com/repo/trunk svn://xxx.com/repo/tags/rb-1.0

Merge trunk to Branch

SVN merge-r lastrevisionmergedfromtrunktobranch:head Svn:/xxx.com/repo/branches/99_branch

Resolve Conflicts

When a conflict occurs, the following message is prompted:

Conflict discovered in ' index.html '.

Select: (p) postpone, (DF) Diff-full, (e) Edit,

(MC) Mine-conflict, (TC) Theirs-conflict,

(s) Show all options:

SVN detects that theres a conflict this and require to take some of action.

If you enter the S option, all SVN conflict resolution options are listed, as follows:

(e) Edit-change merged file in a editor #直接进入编辑

(DF) Diff-full-show All changes made to merged file #显示更改至目标文件的所有变化

(r) resolved-accept merged version of file

(DC) Display-conflict-show all conflicts (ignoring merged version) #显示所有冲突

(MC) Mine-conflict-accept my version to all conflicts (same) #冲突以本地为准

(TC) theirs-conflict-accept their version for all conflicts (same) #冲突以服务器为准

(MF) mine-full-accept My version of entire file (even non-conflicts) #完全以本地为准

(TF) theirs-full-accept their version of entire file (same) #完全以服务器为准

(p) Postpone-mark the conflict to be resolved later #标记冲突, resolved later

(l) Launch-launch External tool to resolve conflict

(s) Show all-show this list

Generally we will choose p to resolve the conflict later, which will generate three files:. Mine, Roldrev,. Rnewrev. Like what:

index.html Index.html.mine index.html.r1 INDEX.HTML.R2

There are roughly a few ways to resolve conflicts:

Manually modify the index.html file and then use the current index.html as the last-submitted version

SVN resolve index.html–-accept Working

Select base version, that is, Index.html.rOLDREV as the last submitted version

SVN resolve Index.html–-accept Base

Use Index.html.rNEWREV as the last-submitted version

SVN resolve index.html–-accept Theirs-full

Use Index.html.mine as the last-submitted version

SVN resolve index.html–-accept mine-full//SVN resolve index.html–-accept theirs-conflict, or with the following command

Submitting Code

Finally, all the confirmation is no problem: code review finished, I feel that the codes are satisfied, and then also merged with other people's changes and no conflict. So just submit the code:

SVN commit/ci-m ' message '

Export Code

You want to export your code without SVN version information, then you can:

SVN Export svn://xxx.com/repo/branches/test folder (local directory)

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.