git checkout -f将该文件后缀删除,变为post-update,post-update文件内容如下: #! .## To enable this hook, rename this file to "post-update".
首先,进入服务器上建好的裸仓的hooks文件夹,配置post-update文件。这这里写了个echo "git push success"做测试用。 pre-applypatch.sample prepare-commit-msg.sample pre-rebase.sample [root@VM_0_16_centos hooks]# vim post-update [root@VM_0_16_centos hooks]# cat post-update echo "git push success" [root@VM_0_16_centos hooks]# 第五 新分支] master -> origin/master [root@VM_0_16_centos testCi]# ls readme.md 第六, 在服务器端的裸仓更新post-update [root@VM_0_16_centos hooks]# cat post-update echo "git push success" cd /home/testCi git pull 如果对shell
gitosis-admin.git/ Reinitialized existing Git repository in /var/spool/gitosis/repositories/gitosis-admin.git/ 设置post-update 脚本权限 chmod 755 /var/spool/gitosis/repositories/gitosis-admin.git/hooks/post-update 至此,服务端配置已经完成。
gitosis-admin.git/ #Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git/ 修改post-update 权限 sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update 客户端克隆仓库进行配置 git clone git
IP:/home/git/hexoblog.git git仓库使用git-hooks自动部署 # 新建部署后文件位置 sudo mkdir -p /home/web/hexo 仓库下新建/hooks/post-update /bin/bash git --work-tree=/home/web/hexo --git-dir=/home/git/hexoblog.git checkout -f 给post-update权限 cd /home/git/hexoblog.git/hooks/ sudo chown -R git:git /home/web/hexo # 赋予其可执行权限 sudo chmod +x post-update
hexo cd /var/repo sudo git init --bare blog.git //git仓库名称 sudo vim /var/repo/blog.git/hooks/post-update # 给post-update授权 的内容如下 cd /var/repo/blog.git/hooks/ sudo chown -R git:git /var/repo/ sudo chown -R git:git /var/www/hexo sudo chmod +x post-update 安装nginx yum install -y nginx nginx --version
gitosis-admin.git/ Reinitialized existing Git repository in /home/gitrepository/gitosis-admin.git/ 对post-update ubuntu@VM-215-209-ubuntu:/home/git$ sudo chmod 755 /home/gitrepository/gitosis-admin.git/hooks/post-update
gitosis-init < /home/git/.ssh/id_rsa.pub 9、 修改 chmod 755 \ /home/git/repositories/gitosis-admin.git/hooks/post-update
taiblog.git #初始化一个名叫taiblog的仓库 4.配置钩子实现自动部署 找到 /home/git/repos/taiblog.git/hooks/post-update.sample 改名post-update wwwroot/taitres.cc --git-dir=/home/git/repos/taiblog.git checkout -f 然后给权限 cd taiblog.git/hooks/ chmod +x post-update
git-repository git --bare init binghe.git cd binghe.git/hooks/mv (2)版本更新钩子,当有版本提交的时候会执行更新 post-update.sample post-update /post-update Nginx 静态访问配置 server { listen 80; server_name git.tl.com; location / { root /data/git-repository; } } (3)重命名钩子 mv hooks/post-update.sample hooks/post-update (4)本地克隆远程服务
基本上,只需要把一个裸版本库放在 HTTP 根目录,设置一个叫做 post-update 的挂钩就可以了(见 Git 钩子)。 此时,只要能访问 web 服务器上你的版本库,就可以克隆你的版本库。 --bare /path/to/git_project gitproject.git $ cd gitproject.git $ mv hooks/post-update.sample hooks/post-update $ chmod a+x hooks/post-update 这样就可以了。 Git 自带的 post-update 挂钩会默认执行合适的命令(git update-server-info),来确保通过 HTTP 的获取和克隆操作正常工作。
基本上,只需要把一个裸版本库放在 HTTP 跟目录,设置一个叫做 post-update 的挂钩就可以了(见 Git 钩子)。 此时,只要能访问 web 服务器上你的版本库,就可以克隆你的版本库。 --bare /path/to/git_project gitproject.git $ cd gitproject.git $ mv hooks/post-update.sample hooks/post-update $ chmod a+x hooks/post-update 这样就可以了。 Git 自带的 post-update 挂钩会默认执行合适的命令(git update-server-info),来确保通过 HTTP 的获取和克隆操作正常工作。
gitosis-init </home/git/.ssh/id_rsa.pub 9、 修改 chmod 755 \ /home/git/repositories/gitosis-admin.git/hooks/post-update
@server:/home/git/repositories/gitosis-admin.git# sudo chmod 755 /home/repo/gitosis-admin.git/hooks/post-update 赋予权限,很重要: chgrp -R www-data /home/repo chmod a+r repo chmod a+x repo mv hooks/post-update.sample hooks/post-update post-update可以更新工作目录,保持与库一致。没有它配置 文件是不会更新的。
基本只需把一个裸版本库放在HTTP根目录上,设置一个叫作post-update的挂钩就可以了。此时,只要能访问Web服务器上你的版本库,就可以克隆你的版本库。下面是设置从HTTP访问版本库的方法。 --bare /path/to/git_project gitproject.git $ cd gitproject.git $ mv hooks/post-update.sample hooks/post-update # 将示例脚本重命名,需要去 #掉.sample脚本才能被识别运行 $ chmod a+x hooks/post-update 这样就可以了。 Git自带的post-update挂钩会默认执行合适的命令(git update-server-info),来确保通过HTTP的获取和克隆操作正常工作。
$ chmod a+x hooks/post-update 这样就可以了。 Git 附带的 post-update 挂钩会默认运行合适的命令(git update-server-info)来确保通过 HTTP 的获取和克隆正常工作。 首先,开启挂钩: $ cd project.git $ mv hooks/post-update.sample hooks/post-update $ chmod a+x hooks/post-update post-update 挂钩是做什么的呢?其内容大致如下: $ cat .git/hooks/post-update #! 接下来,需要手工对该仓库中的 post-update 脚本加上可执行权限: $ sudo chmod 755 /opt/git/gitosis-admin.git/hooks/post-update 基本上就算是好了
On-demand loading for faster startup time Can review and rollback updates Branch/tag/commit support Post-update
实现小程序的持续集成 结合上一篇文章聊过的实现持续集成的方案,我们只需要在git hooks的post-update钩子中,配置上对应小程序的上传脚本即可实现小程的持续集成。
: commit 之前, 添加 message 之后. commit-msg: commit 时调用, 可修改 message, 也可以取消本次提交 post-commit: commit 之后调用 post-update
服务端钩子就是你 push 之后的事情服务器要运行的脚步,有用推的步骤只有一个,所以钩子只有四个 pre-receive 接受之前 update 更新之前 post-update 更新之后 post-receive