1、初始化git仓库
git init
2、设置仓库接受代码提交
允许远程提交代码
git config receive.denyCurrentBranch ignore
3、服务器端编辑钩子文件
vim .git/hooks/post-update
4、 post-update文件内容,当有git提交时可自动更新代码
#!/bin/sh
unset GIT_DIR
cd ..
git checkout -f
5、设置文件权限
chmod +x .git/hooks/post-update