git 服务器

来源:互联网 发布:mac怎么打开mobi文件 编辑:程序博客网 时间:2024/05/18 00:10

参考链接 :https://ourai.ws/posts/deployment-with-git-hooks/


1,处理ssh密钥登陆见上篇


2.服务器需要两个仓库,一个是裸仓库,不能直接看到上传的文件。 一个是工作仓库,需要用钩子代码,把裸仓库里的pull过来。


3. 在本地上传常用:

    $ git init    $ git add yourfile    $ git remote add origin git@yourserverip:/xxx/xxx/xxx    $ git commit -m ''    $ git push origin master
4.在工作仓库需要先运行:
git initgit remote add origin ~/repos/BRIDGE_REPO.gitgit fetchgit checkout master

5.钩子: post-receive
文件名:
代码:
#!/bin/shunset GIT_DIRNowPath=`pwd`DeployPath="../../www"cd $DeployPathgit pull origin mastercd $NowPathexit 0
6.注意权限问题。



原创粉丝点击