git自动同步到站点
2018-06-21 本文已影响0人
陌北v1
服务器端:进入裸仓库:/home/testgit/sample.git
cd /home/testgit/sample.git
cd hooks
这里我们创建post-receive文件
vim post-receive
在该文件里输入以下内容
#!/bin/bash
git --work-tree=/home/www checkout -f
保存退出后,将该文件用户及用户组都设置成git
chown git:git post-receive
由于该文件其实就是一个shell文件,我们还应该为其设置可执行权限
chmod +x post-receive
现在我们可以在本地计算机中修改index.php文件,或者添加一个新文件,提交到远程仓库,然后到/home/www下面,看看有没有我们刚才提交的文件。