Linux SVN use

Source: Internet
Author: User
Tags diff php and svn update

SVN is a version management system, formerly known as CVS, which is the cornerstone of open source software. Even in the case of sufficient communication, many people maintain the same source code must also be chaotic situation, version management system is to solve these problems.


Some of the concepts in SVN:
A. Repository (source code library)
Where the source code is stored uniformly.
B. Checkout (extract)
When you have no source code on your hands, you need to checkout a copy from Repository.
C. Commit (Submit)
When you have changed the code, you need to commit to repository.
D. Update (updated)
When you have checkout a source code, update you can be synchronized with the source code on the repository, you will have the latest changes in your hand.

Centos Build SVN service, effective management code, the following three steps can be quickly done.

1. Installation

[[email protected] ~]# yum Install subversion

[[email protected] ~]# svn-v determine if the installation was successful
Svnserve, Version 1.6.11 (r934486) appears with a type hint stating that the installation was successful.

With SVN software, you also need to build an SVN repository.
[Email protected] ~]# mkdir/opt/svn/repos
[Email protected] ~]# svnadmin create/opt/svn/repos
After executing the above command, we automatically set up several files under repos, namely Conf, Db,format,hooks, locks, README.txt.

2. Configuration

The above operation is very simple, a few commands will be done, the following operation is not difficult.

Go to the above generated folder conf, configure it, there are several files Authz, passwd, svnserve.conf

Where Authz is the permission control, you can set which users can access which directories, passwd is to set the user and password, Svnserve is to set up SVN-related operations.

2 . 1 Set passwd first
[Email protected] ~]# VI passwd
[Users]
# Harry = Harryssecret
# sally = Sallyssecret
Hello=123
User name = password

So we set up a hello user, 123 password

2.2 Set permissions again Authz
[Email protected] ~]# VI authz

[/]
hello= RW

This means that the Hello user has read and write access to all directories, but can also be qualified.
If you use it yourself, read it directly.


2.3 Final Setting snvserv.conf
[Email protected] ~]# VI snsvserv.conf

Anon-access = None # makes non-authorized users inaccessible
auth-access = Write # Enables authorized users to have write permissions
password-db = password
#authz-db = Authz # access Control file
Realm =/opt/svn/repos # Authentication namespace, Subversion is displayed in the authentication prompt and as a keyword for credential caching.
The default configuration is used. All of the above statements must be shelf written, the left cannot be blank, or an error will occur.

Well, with the above configuration, your svn will be OK.

3. Connection

[[email protected] ~]# svnserve-d-r/opt/svn/repos start svn:


If you already have SVN running, you can run it on a different port.
[Email protected] ~]# svnserve-d-r/opt/svn/repos--listen-port 3391

So that the same server can run multiple Svnserver

OK, after the successful launch, you can use it.
It is recommended to use TORTOISESVN with the connection address: Svn://your server addresses (if port is required to specify ports: port number)

After the connection can upload the local files, effectively manage your code.

Open SVN port

Modify
Iptables-i input-p TCP--dport 3690-j ACCEPT
Save
/etc/rc.d/init.d/iptables Save
Restart
Service Iptables Restart
View
/etc/init.d/iptables status

An explanation of the SVN command

1. Checkout files to a local directory

SVN checkout Path (path is a directory on the server)

Example: SVN checkout Svn://192.168.1.1/pro/domain

Shorthand: SVN Co

2. Add a new file to the repository

SVN Add File

Example: SVN add test.php (add test.php)

SVN add *.php (Add all php files in the current directory)

3. Submit the changed files to the repository

SVN commit-m "LogMessage" [-n] [--no-unlock] PATH (use –no-unlock switch if hold lock is selected)

Example: SVN commit-m "Add test file for my test" test.php

Shorthand: svn ci

4. Locking/unlock

SVN lock-m "Lockmessage" [--force] PATH

Example: SVN lock-m "lock test File" test.php

SVN unlock PATH

5. Update to a version

SVN update-r m path

For example:

SVN update If there is no directory behind it, the default is to update all files in the current directory and subdirectories to the latest version.

SVN update-r test.php (Restore the file test.php in the repository to version 200)

SVN update test.php (updated, sync in Repository.) If the prompt expires at the time of submission, it is because of the conflict, you need to update, modify the file, then clear the SVN resolved, and then commit the commit)

Shorthand: SVN up

6. View file or directory status

1) SVN status path (status of files and subdirectories under directory, normal status not shown)

"?: not in SVN control; M: Content modified; C: conflict; A: Scheduled to be added to Repository; K: Locked"

2) SVN status-v path (show file and subdirectory status)

The first column remains the same, the second column shows the work version number, and the third and fourth columns show the last modified version number and the modified person.

Note: The SVN status, SVN diff, and SVN revert three commands can be executed without a network, because SVN retains the original copy of the local version in. svn.

Shorthand: SVN St

7. Delete Files

SVN delete path-m "Delete test Fle"

Example: SVN delete svn://192.168.1.1/pro/domain/test.php-m "Delete test file"

Or go directly to svn delete test.php and then svn ci-m ' delete test file ', which we recommend using this

Shorthand: SVN (del, remove, RM)

8. View Logs

SVN log path

For example: SVN log test.php shows all changes to this file, and its version number

9. View File Details

SVN info Path

Example: SVN info test.php

10. Compare Differences

SVN diff path (compares the modified file to the base version)

Example: SVN diff test.php

SVN diff-r m:n Path (difference between version m and version N)

Example: SVN diff-r 200:201 test.php

Shorthand: SVN di

11. Merge the differences between the two versions into the current file

SVN merge-r m:n Path

For example: SVN merge-r 200:205 test.php (the difference between version 200 and 205 is merged into the current file, but generally conflicts occur and need to be addressed)

12. SVN Help

SVN help

SVN help CI

13. List of files and directories under the repository

SVN list Path

Displays all files and directories belonging to the repository under the path directory

Shorthand: SVN ls

To create a repository:
Terminal input: svnadmin create [path]
The path can be a relative path, for example, currently in the home/user/svn/directory, enter svnadmin create MyProject, the repository will be created in the home/user/svn/directory, a new folder named MyProject, This is the repository file.


To import a file into the repository:
Terminal input: SVN import [Source path] [target repository path]-m [Log information]
The source path can be a relative path, and the import will recursively import all the files and folders under the source path, and the target repository path requires an absolute directory (anyway I'm experimenting with this), such as the repository's directory: home/user/svn/myproject/. It should be written like this: file:///home/user/svn/myproject/
For example, import the current directory into the repository MyProject:
SVN import. File:///home/user/svn/myproject-m "Import File"


Export from repository:
After importing the original file is not included in version management, if you want to get version-controlled files, you need to export from the repository
Terminal input: SVN co [repository path] [export target path]
For example, export files from the MyProject library to the current directory: SVN co file:///home/user/svn/myproject.

Automatically synchronize updates to the Site directory after SVN submits the file


#!/bin/bash
Repos= "$"
rev= "$"

Export LANG=ZH_CN. UTF-8
SVN update/var/www/html/test/
Echo ' Date ', ' WhoAmI ', $REPOS, $REV >>/var/www/svn/test/svn.log

Linux SVN use

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.