ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
![](C:/Users/Administrator/AppData/Local/YNote/data/qq687938EA3FCF98736CBB3342CDC12736/10ba263b51134b52a9c62307392d324c/clipboard.png) [http://blog.sina.com.cn/s/blog\_477071c50102vj31.html](http://blog.sina.com.cn/s/blog_477071c50102vj31.html) svnadmin create /projects/svn/mysvn/web1 svnadmin create /projects/svn/mysvn/web2 svnadmin create /projects/svn/mysvn/web20 查看svn ps -ef|grep svn svnserve -d -r /projects/svn/mysvn --config-file=/projects/svn/mysvn/svnserve.conf --listen-port 3692 svnserve -d -r/home/declan/svnproject //简单的同步 #!/bin/sh export LANG="zh\_CN.UTF-8" REPOS="$1" REV="$2" dateTime=`date +%F` dateTimeMinute=`date +%H%M%S` SVN=/usr/bin/svn WEB=/projects/svn/mysvn/hooktest/hookweb1/web1 #检出的web站点根目录 helloYii为项目目录 LOG=/projects/svn/mysvn/svnlog/svnhooks1\_${dateTime}.log $SVN update $WEB --username linjinkun --password 123456 --no-auth-cache #username你的用户名,password你的密码 \# chmod -R 777 post-commit #svn checkout svn://139.199.86.199:3692/web2 --username linjinkun --password 123456 //更新才同步 #!/bin/sh export LANG="zh\_CN.UTF-8" REPOS="$1" REV="$2" SVN\_PATH=/usr/bin/svn SVNDATA\_PATH=/projects/svn/mysvn/web2 WEB\_PATH=/projects/svn/mysvn/hooktest/hookweb2/web2 LOG=/projects/svn/mysvn/svnlog/svnhooks2\_${dateTime}.log LOG\_PATH=/projects/svn/mysvn/svnlog/svn\_update2.log $SVN\_PATH update $WEB\_PATH --username linjinkun --password 123456 --no-auth-cache #username你的用户名,password你的密码 for change\_dir in `svnlook dirs-changed $SVNDATA\_PATH` do $SVN\_PATH update --username linjinkun --password 123456 --no-auth-cache -N $WEB\_PATH/$change\_dir 2>>$LOG\_PATH done svn post-commit钩子实现代码上传到web目录例子 作者:用户 来源:互联网 时间:2016-05-24 09:48:45 [权限](https://yq.aliyun.com/ziliao/topic_186)[服务器](https://yq.aliyun.com/ziliao/topic_624)[测试](https://yq.aliyun.com/ziliao/topic_984)[代码](https://yq.aliyun.com/ziliao/topic_3123) ![svn post-commit钩子实现代码上传到web目录例子 -](C:/Users/Administrator/AppData/Local/YNote/data/qq687938EA3FCF98736CBB3342CDC12736/9cb67fb8d7684aaebca831c687a60422/15.jpeg) 摘要: 本文讲的是svn post-commit钩子实现代码上传到web目录例子, 说明 最近在window下用虚拟机装了一个ubuntu系统,搭建好了PHP环境,为了在window下方便查看代码,于是想搭建个svn,直接将代码提交到对应的web目录下,于是用到了SVN的钩子, svn目录:/home/svn 站 [教程](https://www.aliyun.com/jiaocheng/)[采购季五折](https://promotion.aliyun.com/ntms/act/season.html)[Mysql](https://yq.aliyun.com/sqlarticle)[备案](https://beian.aliyun.com/)[文档](https://help.aliyun.com/)[域名](https://wanwang.aliyun.com/)[whois查询](https://whois.aliyun.com/)[PHP教程](https://yq.aliyun.com/php)[备份](https://www.aliyun.com/jiaocheng/178488.html) 说明 最近在window下用虚拟机装了一个ubuntu系统,搭建好了[PHP](https://yq.aliyun.com/php/)环境,为了在window下方便查看代码,于是想搭建个svn,直接将代码提交到对应的web目录下,于是用到了SVN的钩子, svn目录:/home/svn 站的目录:/var/www/[html](https://edu.aliyun.com/jiaocheng/291) 实现 1.找到svn项目的hooks目录,这里是/home/svn/hooks。目录中默认会几个对应操作的钩子模板,我们需要创建一个post-commit的文件 2.新建post-commit,内容如下 #!/bin/sh REPOS="$1" REV="$2" dateTime=`date +%F` dateTimeMinute=`date +%H%M%S` SVN=/usr/bin/svn # 你svn的绝对路径 此路径可以用 which svn命令查找 WEB=/var/www/html/helloYii  #检出的web站点根目录 helloYii为项目目录 LOG=/tmp/svnhooks\_${dateTime}.log $SVN update $WEB --username username --password password --no-auth-cache  #username你的用户名,password你的密码 3.修改post-commit权限 chmod +x post-commit \# chmod -R 777 post-commit 4.Checkout一份代码到web服务器上 \# cd /home/www/html \# sudo svn checkout svn://127.0.0.1/helloYii 5.测试 测试的话,我这里是在本地修改版本库,点commit,然后再看web(nginx)服务器上的数据是否更新来测试 以上是云栖社区小编为您精心准备的的内容,在云栖社区的博客、问答、公众号、人物、课程等栏目也有的相关内容,欢迎继续使用右上角搜索按钮进行搜索权限 , 服务器 , 测试 代码 svn 钩子 post commit、post commit例子、svn post commit、svn post commit 详解、svn post commit hook,以便于您获取更多的相关知识。 #!/bin/sh export LANG="zh\_CN.UTF-8" REPOS="$1" REV="$2" SVN\_PATH=/usr/bin/svn SVNDATA\_PATH=/var/www/svn WEB\_PATH=/root/test LOG=/tmp/svnhooks\_${dateTime}.log LOG\_PATH=/var/log/svn\_update.log for change\_dir in `svnlook dirs-changed $SVNDATA\_PATH` do $SVN\_PATH update --username linjinkun --password 123456 --no-auth-cache -N $WEB\_PATH/$change\_dir 2>>$LOG\_PATH done