SVN Learning Notes

Source: Internet
Author: User
Tags commit mixed mkdir svn svn update ssh

Reprinted from: http://blog.csdn.net/tengbaichuan/article/details/10632349

------------------Reference Document--------------------
Official document: http://www.subversion.org.cn/svnbook/includes downloadable PDFs and one page of HTML.
Configuration document: Go to ubuntu wiki ~ ~ If you use SVN + ssh, basically do not configure, press the following "quick work".

------------------Quick work:-------------------
1. Build the repository:
My approach is to use SVN+SSH to access the repository, which means:
Instead of starting the Svnserve daemon, each time SSH connects to the repository, it automatically starts Svnserve, and then exits the svnserve process after the work is done. These things are local svn call ssh let it do that. While the identity of the initiated Svnserve process is the identity of the SSH user, and the SSH user comes from the system user, this is the advantage of this method: with the system users.

Because of this, if each user is able to read and write to the repository, it depends on the repository's permission settings, which is the permission setting of the file you generated with Svnadmin create.
My strategy was to have some users read and write to the repository, I created an SVN user, and an SVN group, and then built the repository under/HOME/SVN. Then all the users who need to access SVN, add to the SVN group, and set up all the files of the repository, the SVN group can read and write.

On the repository machine, the following are the details:
AddUser SVN # Create SVN user and SVN group
Gpasswd-a Fengyi SVN # Add Fengyi user to SVN group
Svnadmin Create/home/svn/buptnic # Create a repository Buptnic
Chmod-r G+w/home/svn/buptnic # Make all the files writable for the group (because the default is generally group readable)
The above two steps, can also be changed, first with Umask 0002, and then with Svnadmin the same effect. Because the default umask is typically 0022, this removes the Write permission for the group.

Note: Once svnadmin create, other things should be done with SVN on the working copy machine. ———— Point is that most of the SVN subcommands end up working with the repository, but in two ways. If the subcommand has a URL, it is generally directly operated on the repository, if not with a URL, it is generally the work copy first, and then commit the repository into effect. Of course, a lot of commands, that is, you can take the URL, or do not take, usually the first update, and then change the working copy, and then commit.

On the working copy machine, the following are the details:
SVN mkdir Svn+ssh://svn@210.25.137.252/home/svn/buptnic/flow # Build Flow project directory
SVN mkdir svn+ssh://svn@210.25.137.252/home/svn/buptnic/flow/trunk # Build Flow/trunk Directory
SVN mkdir svn+ssh://svn@210.25.137.252/home/svn/buptnic/flow/branches # Build Flow/branches Directory
SVN mkdir svn+ssh://svn@210.25.137.252/home/svn/buptnic/flow/tags # Build Flow/tags Directory

SVN import/home/echo/src Svn+ssh://svn@210.25.137.252/home/svn/buptnic/flow/trunk # Imports the source files under the local src into the trunk directory of the repository. Note that trunk is the main branch, and the general habit is to put anything, including documents, to third-party libraries.

Then, OK, you can find a place, with Fengyi users do checkout.
SVN checkout Svn+ssh://fengyi@210.25.137.252/home/svn/buptnic/flow

Note: In the repository, although you build those directories through mkdir, upload those files, but you are not directly visible in the/home/svn/buptnic/flow, they are placed in the flow of the DB directory, is the virtual file system.

2. Basic User Operation principle:
(1) Whether it is a repository or a working copy, their maintenance files are in their folders, so if you want to delete them, directly with the file system RM can be completely deleted.
(2) with the SVN subcommand, the direct operation of the repository must be a form of the URL, not the normal file path, including on the repository machine ..... However, svnadmin and other commands are directly using the normal file path to manipulate the repository and require execution on the repository machine.
(3) in which directory of the working copy executes the SVN subcommand, the last parameter of the command, the default is the current directory, which allows the effect of the command to start from the current directory.
This has one from each directory. SVN can see that each directory has a maintenance file, which works alone. This is also the basis for different parts of the working copy to allow different version numbers.
(4) Commit succeeds only if the version number of all files in the current directory equals the current version number of the repository.
The different parts of the working copy allow different version numbers, so when you commit, there may be a different version number in the current directory, such as each subdirectory, and if there is a lower version number than the Repository, the commit will not succeed, the message is ... out of date ..., You need to update it once, and then commit again. Of course, many other situations can also lead to this situation, most typically the case of a file conflict in (5).
(5) operate on the working copy first, then commit to the repository.
In addition to modifying anything other than the file, it is done with the SVN subcommand, such as adding a file, creating it, and adding it to the local copy with SVN Add. When you think the work copy work is over, you can commit it to the repository to update the repository to the new revision.
(6) Conflict resolution
The best way to resolve a conflict is for two people not to edit the same file. Otherwise, see below or the information, you need to update once, to merge two people's files (because the other people commit, the version number in the repository is higher than their own, they will not commit the success of commits, need to update first). If you need to resolve the conflict manually, see the following workaround.
(7) Yes, if the two branches of independent development for too long, then the inevitable changes in the larger, the merge will conflict, you still have to manually solve.
Merge and update conflicts, the resulting conflict temporary file name is different, but the source file is marked by the conflicting flag, you only need to change the source file. Inside <<< to >>> part, is the conflict area, that is, SVN thinks, in this area, two files each developed their own changes, so the first file modification, put in <<< and = =, the second file modification, put to = = and >>>, you choose which changes to keep. If a modification is empty, such as = = = and no code in >>>, then "Modify" is the "delete" action.
So, when we merge the branches file into the trunk, we have to consider clearly, because branches is modifying the bug, and the trunk is adding new features, in order to branches bug changes through the merge into the trunk, it is likely to lead to conflict.
(8) Revert and merge
Revert is restored in the version, that is, when commit, is a version, then, if you change anything, but there is no commit, you can revert to the state after the last commit. Revert does not rely on the repository, only the. SVN directory to maintain information.
The merge, however, is dependent on the repository and does the difference between versions, thus acting on a directory. Causes the content to revert to a version state.
(9) Forgot the command, use SVN help Subcmd to consult.
diff, Status, log how to use AH?
Below is the output of the SVN status-v in the trunk directory:
Fengyi.
Fengyi Sheep
Fengyi sheep/sheep.c
SVN main.c
Fengyi Cow
Fengyi cow/main2.c
Note that the first column is the version number of the current working copy because the version number of all files is up-to-date after trunk update. However, the following column of numbers indicates that the file has not been changed since that version number (there is no guarantee that the repository is not updated). You use SVN log to see that file, you can only see that version, see the current working copy of the version number (no change, no commit, how can have log.) )


--------------------Note---------------------

Chapter I. Basic CONCEPTS
SVN is a file server capable of tracking data changes
"Copy-Modify-merge" model instead of "lock-Modify-unlock" (see saved diagram)
Whenever the repository is committed by a user commits a commit, the filesystem enters a new state, called a revision (revision), each revision is given a unique natural number, and commit is obviously an atomic operation. At the same time, it can be seen that the repository does not have the concept of fallback, only the working copy has this concept, the repository has just been moving forward.
(Many other version control systems use a policy with a revision number for each file, so they feel a little different.) )
In the SVN concept, the revision of the repository is uniform, that is, the "revised version" of each file is the same at any time.
However, the working copy is often a "mixed revision" because you submit only one file, causing the revision in the repository to add 1, and the revised version of the file in your working copy also adds 1, but the other files in the working copy can only maintain the original version number unless you update it once.
This is a useful feature that allows any part of a working copy to move forward or backward in history.

One of the basic tenets of SVN is that "push" actions do not cause "pull" and vice versa.


SVN commit & SVN Update and four states (whether or not modified + current)

SVN status--verbose check for "Mixed revisions"
SVN log displays historical modification information for a file or directory.

$ svn Checkout Http://svn.example.com:9834/repos
$ svn Checkout File:///path/to/repos
$ svn Checkout File://localhost/path/to/repos
C:\> SVN Checkout File:///X:/path/to/repos

$ svn Checkout Http://svn.example.com/repos/calc
$ svn commit button.c-m "Fixed a typo in button.c."
$ SVN update

Subversion can access the repository in a variety of ways!!
———— One important point is that the various SVN subcommands have direct access to the repository. If you are on the repository machine, then use file:///, if you are on your own machine, use the following four ways.
———— But, how do you only operate the local copy of the work, thought you want to change in the local, after the change to commit, then do not add these things, directly is the file name, or do not add good.
Mode access method
file:///Direct repository access (Local disk)
HTTP//By configuring the WebDAV protocol for subversion's Apache server
https://is similar to/HTTP, but includes SSL encryption.
svn://protocol customized by Svnserve service
SVN+SSH://is similar to svn://, but is encapsulated via SSH.

But note: The general practice, or first update,merge,copy and other commands to get the repository data to work copies, modify the work copy, then commit, which will lead to the repository into the next revision.
If you work directly in the repository, such as Copy,delete, it will also allow the repository to enter the next reversion.

Chapter II Basic use
SVN help subcommand
1. Create a version library
Create a new repository name Newrepos
$ svnadmin Create/usr/local/svn/newrepos
The Mytree file is not versioned, the repository is imported, the file is placed under Some/project, and there is no Mytree folder.
$ svn import mytree file:///usr/local/svn/newrepos/some/project-m "Initial import"
Note: The path after import can be on the repository or on your own machine. In general, you can import the code on your machine directly to the repository on the server.
Lists the files under a folder in the Newrepos repository.
$ SVN List File:///usr/local/svn/newrepos/some/project

Recommended repository layouts: There are two items in paint and calc
$ SVN List File:///usr/local/svn/repos
/paint/trunk
/paint/branches
/paint/tags
/calc/trunk
/calc/branches
/calc/tags
/vender/vendorlib1/current #供方最新版本
/vender/vendorlib1/1.0 #上次最新版本的快照 (SVN copy)

Note: Folders are created with SVN mkdir. See if you are on the repository host or the working copy host, select one of the above URLs to operate the repository.

2. Initialize the Checkout
Create a working copy locally, which may simply be a folder in a repository.
$ svn Checkout Http://svn.collab.net/repos/svn/trunk
Ditto, except that the SUBV directory is created locally,

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.