Build SVN server and automatically update project files to Web publishing directory (www) under Linux

Source: Internet
Author: User
Tags diff svn client svn update

one, Linux server-side Configuration

[email protected] ~]# Rpm-qa | grep Sub

Subversion-libs-1.7.14-10.el7.x86_64

Subversion-1.7.14-10.el7.x86_64

[email protected] ~]# Ps-ef | grep SVN

Root 21019 20613 0 21:57 pts/0 00:00:00 grep--color=auto svn

[email protected] ~]# Mkdir-p/opt/svn/repo

[email protected] ~]# svnserve--version

svnserve, version 1.7.14 (r1542130)

Compiled Nov 20 2015, 19:25:09


Copyright (C) the Apache software Foundation.

This software consists of contributions made by many people; See the NOTICE

File for more Information.

Subversion is open source software, see http://subversion.apache.org/


The following repository Back-end (FS) modules is available:


* Fs_base:module for working with a Berkeley DB repository.

* Fs_fs:module for working with a plain file (FSFS) repository.


Cyrus SASL Authentication is Available.


[email protected] ~]# svnadmin create/opt/svn/repo/

[email protected] ~]# cd/opt/svn/repo/

[email protected] repo]# pwd

/opt/svn/repo

[[email protected] repo]# ls

Conf db format Hooks Locks README.txt

[email protected] repo]# CD conf/

[email protected] conf]# pwd

/opt/svn/repo/conf

[[email protected] conf]# ls

Authz passwd svnserve.conf

[email protected] conf]# Vim Authz

Note: Authz finally add the following two lines (these two lines resolve the SVN client to solve the authorization failed Problem)

[/]

* = RW

[email protected] conf]# Vim passwd

Note: passwd Modified To:

[users]

admin = 123456//the username and password here set themselves

[email protected] conf]# Vim svnserve.conf

Note: the configuration is as Follows:

Anon-access = None #匿名访问的权限, can be read,write,none, default is read

auth-access = Write #使授权用户有写权限

Password-db = passwd #密码数据库的路径

Authz-db = Authz #访问控制文件

Realm =/opt/svn/repo #认证命名空间, Subversion is displayed in the authentication prompt and is cached as a voucher #的关键字

[[email protected] conf]# CD

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

-D indicates background run

-R specifies that the root directory is/opt/svn/

[email protected] ~]# Ps-ef | grep SVN

Root 21122 1 0 22:21? 00:00:00 svnserve-d-r/opt/svn/

Root 21124 20613 0 22:21 pts/0 00:00:00 grep--color=auto svn

[email protected] ~]# NETSTAT-ANTLP | grep SVN

TCP 0 0 0.0.0.0:3690 0.0.0.0:* LISTEN 21122/svnserve



Ii. Introduction to the use of Linux clients

1. Checkout files to a local directory

[[email protected] home]# CD

[email protected] ~]# cd/home/

[[email protected] home]# ls

[email protected] home]# svn checkout Svn://127.0.0.1/repo #简写: SVN co

Checked Out Revision 0.

[[email protected] home]# ls

Repo

2. Add a new file to the repository

[email protected] home]# CD repo/

[[email protected] repo]# ls

[email protected] repo]# Touch test.txt

[[email protected] repo]# ls

Test.txt

[[email protected] repo]# svn add test.txt

A Test.txt

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)

[[email protected] repo]# svn commit-m "add testing" test.txt #简写: svn ci

Adding Test.txt

Transmitting file Data.

Committed Revision 1.

[[email protected] repo]# ls

Test.txt

[email protected] repo]# Vim test.txt

[email protected] repo]# Cat Test.txt

Testing

Testing

Testing

Testing

Testing

Testing

Testing

Testing

[email protected] repo]# svn commit-m "add testing something" test.txt

Sending Test.txt

Transmitting file Data.

Committed Revision 2.

4. Delete Files

SVN delete path-m "delete test fle"

Example: First step: svn delete svn://192.168.10.151/pro/domain/test.php-m "delete test file"

Step Two: SVN Commit

Step three: SVN update

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)

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. Restore Local Modifications

SVN revert: restores the original unchanged working copy file (restores Most of the local modifications). Revert

Usage: revert PATH ...

Note: The Notebook command will not access the network and will release the conflicting Condition. But it won't recover.

Directories that were deleted

7. Conflict Resolution

SVN resolved: removes the "conflicting" status of the working Copy's directory or File.

Usage: Resolved PATH ...

Note: The book command does not resolve the conflict by syntax or remove the conflict token; it simply removes the conflicting

file, and then allow PATH to submit again.


8. Locking/unlock

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

Example: svn lock-m "lock test file" test.php

SVN unlock PATH

9. 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

10. View Logs

SVN log path

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

11. View File Details

SVN info Path

Example: SVN info test.php

12. 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

13. 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)

14. SVN Help

SVN help

SVN help CI


third, automatically update the project file to the Web publishing directory (www)

1, Check out (checkout) to the local directory Is/home/repo

[[email protected] repo]# ls

index.php test.txt

[email protected] repo]# CD.

[[email protected] home]# ls

Repo

[email protected] home]# MV Repo/www/#将检出到本地的版本目录更名为web发布目录

[[email protected] home]# ls

Www

[email protected] home]# CD www/

[[email protected] www]# ls

index.php test.txt

2. Automatic Update via script file

Automatically check out files from SVN in real time and sync to Web site root using SVN post-commit implementation

[email protected] ~]# cd/opt/svn/repo/

[[email protected] repo]# ls

Conf db format Hooks Locks README.txt

[email protected] repo]# CD hooks/

[email protected] hooks]# pwd

/opt/svn/repo/hooks

[[email protected] hooks]# ls

Post-commit.tmpl Post-unlock.tmpl Pre-revprop-change.tmpl

Post-lock.tmpl Pre-commit.tmpl Pre-unlock.tmpl

Post-revprop-change.tmpl Pre-lock.tmpl Start-commit.tmpl

[email protected] hooks]# CP Post-commit.tmpl Post-commit

[[email protected] hooks]# ls

Post-commit Post-revprop-change.tmpl Pre-lock.tmpl Start-commit.tmpl

Post-commit.tmpl Post-unlock.tmpl Pre-revprop-change.tmpl

Post-lock.tmpl Pre-commit.tmpl Pre-unlock.tmpl

[email protected] hooks]# CP Post-commit.tmpl Post-commit

[email protected] hooks]# Vim Post-commit

[email protected] hooks]# > Post-commit

[email protected] hooks]# Vim Post-commit

******************************************************************************************

Input:

#!/bin/sh

Export Lc_ctype= "zh_cn. UTF-8 "

Svn=/usr/bin/svn

Web_path=/home/www #要强制更新的目录

Svn_user=admin

svn_pass=123456

$SVN update $WEB _path--username $SVN _user--password $SVN _pass #执行更新

******************************************************************************************

[email protected] hooks]# ll Post-commit

-rw-r--r--. 1 root root (Apr) 00:21 post-commit

[email protected] hooks]# chmod a+x post-commit #给予执行权限

[email protected] hooks]# ll Post-commit

-rwxr-xr-x. 1 root root (Apr) 00:21 post-commit

[email protected] hooks]# Cat Post-commit

#!/bin/sh

Export Lc_ctype= "zh_cn. UTF-8 "

Svn=/usr/bin/svn

Web_path=/home/www #要强制更新的目录

Svn_user=admin

svn_pass=123456

$SVN update $WEB _path--username $SVN _user--password $SVN _pass #执行更新

[email protected] hooks]# pwd

/opt/svn/repo/hooks


Note: file/opt/svn/repo/hooks (commonly known as Hooks)/post-commit belongs to Automatic Execution.




This article is from the "mq_douer" blog, make sure to keep this source http://douer.blog.51cto.com/6107588/1915293

Build SVN server and automatically update project files to Web publishing directory (www) under Linux

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.