This document describes how to automatically synchronize code files to the website directory of the server after local SVN submission through the HOOK script of the SVN.

If there are now:

An item in the SVN repository: / SVN /rootwww/

Website directory: /data/ WWW /

We’ll start by checking out a project from the SVN repository to the website directory:

SVN co SVN: / / 192.168.5.5 rootwww - username admin -- password 123456Copy the code

At this point, the web site directory has become a working copy of SVN, and the SVN hooks are used to update the working copy automatically.

Create a new post-commit hook:

If the file name is post-commit. TMPL needs to be changed to post-commit

vim /svn/rootwww/hooks/post-commitCopy the code

Add the following:

#! /bin/sh
REPOS="The $1"
REV="$2"
export LANG="zh_CN.UTF-8"    # Prevent garbled characters
svn update /home/www/ --username Hwei --password 123456 --no-auth-cache The login account password is not cached
Copy the code

Note: Do not omit the #! In the first line. /bin/sh, otherwise post-commit will report an error code 255.

After saving the file, change the file permission to 777. Otherwise, the SVN cannot invoke the command:

chmod 777 /svn/rootwww/hooks/post-commit
Copy the code


End!!!!!