git实现自动化部署,同时push到多个远程仓库
2017-05-19 15:06
459 查看
方法一、
1、先在服务器创建裸仓库 git init --bare <repo> 裸仓库是可以被正常
git init --bare test.git
2、配置hooks 钩子
cd test/test.git/hooks/
vi post-receive
#!/bin/sh
git --work-tree=/root/test --git-dir=/root/test/test.git checkout -f #/root/test是代码目录,/root/test/test.git 是裸仓库
3、配置本地git conf
vi conf
[remote "web"]
url = git@git.oschina.net/mytest.git #远程仓库
url = 账号@ip:/root/test/test.git #服务器裸仓库
4、测试
git push web master
方法二、
1、配置码云
配置url和密码 (http://127.0.0.1/git_hooks,密码:123456)
2、配置服务器端
cd /home/backend/www/aw
git pull origin master
4、over
1、先在服务器创建裸仓库 git init --bare <repo> 裸仓库是可以被正常
clone和
push更新的, 裸仓库不包含工作区,所以并不会存在在裸仓库上直接提交变更的情况
git init --bare test.git
2、配置hooks 钩子
cd test/test.git/hooks/
vi post-receive
#!/bin/sh
git --work-tree=/root/test --git-dir=/root/test/test.git checkout -f #/root/test是代码目录,/root/test/test.git 是裸仓库
3、配置本地git conf
vi conf
[remote "web"]
url = git@git.oschina.net/mytest.git #远程仓库
url = 账号@ip:/root/test/test.git #服务器裸仓库
4、测试
git push web master
方法二、
1、配置码云
配置url和密码 (http://127.0.0.1/git_hooks,密码:123456)
2、配置服务器端
@login.route('/git_hooks', methods=['POST']) def git_payload(): data = request.get_json() password = '123456' if data.get('password', None) == password: if data.get('hook_name') == "push_hooks": try: cmd_output = subprocess.Popen( [". /home/git_sh.sh"], shell=True) return jsonify({'msg': str(cmd_output)}) except subprocess.CalledProcessError as error: return jsonify({'msg': str(error.output)}) else: return jsonify('invalid hooks') else: return jsonify('invalid hash')3、编辑git_sh.sh脚本
cd /home/backend/www/aw
git pull origin master
4、over
相关文章推荐
- git hook远程仓库实现网站的自动部署
- GIT 中同时 push 代码到多个远程仓库
- IDEA/Git 设置多个push远程仓库或者同时提交多个push仓库
- 【Git学习笔记】将标签push到远程仓库
- git push github 远程仓库 要求每次输入账号密码问题
- Fabric自动化运维工具实现远程SSH部署及系统管理
- Git实现从本地加入项目到远程仓库
- git本地仓库首次push到远程仓库出现错误 ! [rejected] master -> master (fetch first)
- Git同时提交到多个远程仓库
- Git -- 创建一个远程git仓库和做初始化"push"
- Git实现从本地添加项目到远程仓库
- git push :推送本地更改到远程仓库的三种模式
- 创建局域网内远程git仓库,并将本地仓库push推到远程仓库中
- Git实现从本地添加项目到远程仓库
- Git实现从本地添加项目到远程仓库
- 创建局域网内远程git仓库,并将本地仓库push推到远程仓库中
- Eclipse关联GitHub实现版本控制[一般下载的eclipse里都自带git插件,然后设置本地仓库和远程仓库就可以]
- Git中git push到远程仓库不被授权的问题
- 使用Git时,本地仓库向远程仓库push失败问题解决
- git push 代码到远程仓库错误1