Git管理多个远程仓库(GitHub和Coding)
2015-12-23 19:06
309 查看
两个空代码仓库
如果是两个仓库都是空的,就直接在 .git/config 中添加远端地址[remote "origin"] url = https://github.com/younglaker/octjs.git url = https://git.coding.net/laker/octjs.git #添加新地址 fetch = +refs/heads/*:refs/remotes/origin/*
地址是配好了,但是还要注意分支一致。我这里都用master,就不会有问题。
非空代码仓库
假设Github中使用了一段时间,想在Coding里备份一个,要想把两边仓库同步到一致的状态。线到Coding新建仓库,获得地址后, .git/config 中添加Coding的远端地址,这里我命名为coding:
[remote "origin"] url = https://github.com/younglaker/octjs.git fetch = +refs/heads/*:refs/remotes/origin/* [remote "coding"] #添加coding远端 url = https://git.coding.net/laker/octjs.git #远端地址 fetch = +refs/heads/*:refs/remotes/coding/* #注意修改远端名
使用Git GUI 获取 Coding上的信息,你也可以使用命令行完成一下操作:
合并:
推送,记得选Coding远端:
然后再修改 .git/config ,吧Coding也用origin远端名,下次就只用 git push 就可以推送到两边了。重启 Git GUI 也只剩一个远端了:
[remote "origin"] url = https://github.com/younglaker/octjs.git url = https://git.coding.net/laker/octjs.git fetch = +refs/heads/*:refs/remotes/origin/*
Github 不为空,Coding为新建项目
那就在Coding新建项目时导入Github项目,本地git配置改为:[remote "origin"] url = https://github.com/younglaker/octjs.git url = https://git.coding.net/laker/octjs.git fetch = +refs/heads/*:refs/remotes/origin/*
相关文章推荐
- php中工厂方法的两个特殊例子
- Spring AOP AspectJ注解和XML配置两种实现(Maven构建)
- Ubuntu 14.04安装JDK1.8.0_25与配置环境变量
- 终于知道了什么事JavaBean
- jdk线程池详解
- lua练手基础
- Javac和Java
- 我的java基础学习
- win7下反汇编程序程序基址改变问题
- C# 动态链接库的创建
- How to convert Java String into byte[]?
- 用pycharm+django开发web项目
- 给php开启mysql扩展
- springboot构建solr查询实例
- java Swing 弹出新对话框的方法,以及关闭新对话框遇到的问题和解决方法
- Python 网页爬虫、 文本处理、 科学计算 、机器学习、数据挖掘 兵器谱
- C++中实现从std::string类型到bool型的转换
- Spring MVC 配置Controller详解
- phpStudy报错
- python语言基础学习