美文网首页
git利用post-receive自动化部署

git利用post-receive自动化部署

作者: 迟钝的牛 | 来源:发表于2019-12-06 11:24 被阅读0次

要求

实现git push 直接完成代码部署到服务器的目录

实现方式

利用git的hooks中的post-receive来实现代码提交完成之后的动作。将仓库指定一个--work-tree然后进行检出操作checkout --force

进入创建的仓库

$ cd /var/repo/hexo_static.git

//配置钩子

$ vim post-receive

将入下代码复制进去 ,并保存退出

#!/bin/bash

git --work-tree=/var/repo/hexo --git-dir=/var/repo/hexo_static.git checkout -f

给钩子文件添加执行权限

$ chmod +x post-recevie

相关文章

网友评论

      本文标题:git利用post-receive自动化部署

      本文链接:https://www.haomeiwen.com/subject/zbgsgctx.html