git合并两个不同的仓库
目前开发是2个仓库,线上仓库online_a(对应的branch分支为online),测试环境online_b(对应的branch分支为demo),测试环境需要时刻保持onine_a上的最新稳定稳定代码同步过来。如何合并呢?特此记录下:
在测试仓库onine_b 上执行:
1:测试仓库添加远程生产仓库(切换到自己的测试仓库下执行以下命令,比如我的当期测试online_b.git)
git remote add online_a git@github.com:fantasy/online_a.git //将online_a作为远程仓库,添加到online_b中,设置别名为online_a(自定义,这里我是为了方便区分仓库名)
2:从远程仓库下载,这时我们弄个新的
git fetch online_a //从online_a仓库中抓取数据到本仓库,注意这里是上面设置的别名
$ git fetch online-a
remote: Counting objects: , done.
remote: Compressing objects: % (/), done.
remote: Total (delta ), reused (delta )
Receiving objects: % (/), 2.44 MiB | 214.00 KiB/s, done.
Resolving deltas: % (/), completed with local objects.
From git@github.com:fantasy/online_a.git* [new branch] demo -> online-backend/demo
* [new branch] online -> online-backend/online
* [new tag] demo-last-bad -> demo-last-bad
* [new tag] demo-last-ok -> demo-last-ok
* [new tag] v2.-beta -> v2.-beta
* [new tag] v2.-days -> v2.-days
* [new tag] v2.-dist -> v2.-dist
* [new tag] v2.-dist -> v2.-dist
* [new tag] v2.-nosmartbid -> v2.-nosmartbid
* [new tag] v2.2demo -> v2.2demo
* [new tag] v2.-bad-smartbid -> v2.-bad-smartbid
* [new tag] demo-no-score -> demo-no-score
* [new tag] tmp-repay-v1 -> tmp-repay-v1
* [new tag] tmp-repay-v2 -> tmp-repay-v2
* [new tag] transfer-dep-last -> transfer-dep-last
* [new tag] transfer-dep-ok -> transfer-dep-ok
3:将online_a仓库抓去的online分支作为新分支checkout到本地,新分支名设定为online_repo1
$ git checkout -b online_repo1 online-a/online //注意这里也是别名online_a
Switched to a new branch 'online_repo1'
Branch 'online_repo1' set up to track remote branch 'online' from 'online-a'.
4:切换回本地测试的online_b的demo分支
$ git checkout demo
Switched to branch 'demo'
Your branch is up to date with 'origin/demo'.
5:将online_repo1合并入demo分支
git merge online_repo1
6:解决冲突:
git add .
git commit -m "合并"
git push online_repo1 online_a:online //上传到远程库
git checkout demo
git merge online_repo1
git branch -d online_repo1
总结:
- 大致思路是伪造远程的repo1仓库为repo2的一个分支,然后合并进来;
- 若是文件有冲突、或要建立子目录,建议在repo1中先解决,再进行如上操作。
git合并两个不同的仓库的更多相关文章
- Git 合并两个不同的仓库
目录 第一步. 下载需要合并的分支 第二步. 添加需要合并远程仓库 第三步. 把base远程仓库中数据抓取到本仓库 第四步. checkount切换到base分支上,命名为 asf 第五步. 合并 总 ...
- git 合并两个仓库
我有两个仓库,一个是gitbook在写一本 一个是放在github的垃圾,这个是我想要开个人网站,但是做的还是不行https://github.com/lindexi/lindexi.github.i ...
- 如何用 Git 合并两个库,并保留提交历史
转载自 https://segmentfault.com/a/1190000000678808 背景 一个中型规模项目,开始规划时就打算采用 C/S 架构,后端是单纯的 API 服务,前端在 Web ...
- Git 合并两个分支内容
1,将开发分支代码合入到master中 git checkout dev #切换到dev开发分支 git pull git checkout master git merge dev #合并dev分支 ...
- git 合并两个分支的某个文件
软件开发基本都是多个feature分支并行开发,而在上线前有可能某个分支的开发或测试还没有完成,又或者是产品调整,取消了该分支功能的上线计划,我们在release前不合并该分支即可,然而如果该分支中的 ...
- 合并两个git仓库
现有两个git仓库ekt_zy.ekt_zijian,需要把ekt_zijian项目中的代码合并到ekt_zy项目中. 1 将ekt_zijian作为远程仓库.添加到ekt_zy中,设置别名为ziji ...
- Git提交到多个远程仓库(多看两个文档)
Git提交到多个远程仓库(多看两个文档) 一.总结 一句话总结: 二. Git提交到多个远程仓库(多看两个文档) 有两种做法,先看第一种 一.通过命令行进行操作 例如我有下面两个仓库: Mybatis ...
- git合并不同仓库下的分支
1.把lib合并到pro $ git remote -v origin git@192.168.1.1:lib.git (fetch) origin git@192.168.1.1:lib.git ( ...
- Git合并不同url的项目
本文由云+社区发表 作者:工程师小熊 摘要:为了让项目能实现Git+Gerrit+Jenkin的持续集成,我们把项目从Git上迁移到了Gerrit上,发现有的同事在老Git提交代码,因为Gerrit做 ...
随机推荐
- [LeetCode] Smallest Subtree with all the Deepest Nodes 包含最深结点的最小子树
Given a binary tree rooted at root, the depth of each node is the shortest distance to the root. A n ...
- codeforces 13 b
给你三根线段判段是否组成了A 条件,两条线段交于端点并且夹角不大于90,第三条线段端点在两条线段上并且划分的大小满足 大:小<4:1 注释很全.(主要是我记不清楚了,,好像过了一个多星期了) # ...
- Oracle数据库在plsql中文乱码,显示问号????
1.错误显示结果: 2.错误的原因: SqlPlus乱码与操作系统用户中的NLS_LANG这个环境变量有关系,如果这个与数据库字符集不一致的话就会产生乱码 3.解决方法1:(配置环境变量) 1.sel ...
- Luogu P1894 [USACO4.2]The Perfect Stall
传送门 是道绿题???二分图(网络流)不应该是蓝打底??? 这题浏览一遍就知道是二分图(网络流)算法喽,二分图代码太短,不想写(←这人???),所以就拿网络流练练手. 设源点S=0,汇点T=n+m+1 ...
- SVG PATH 生成器
参考网站:http://dayu.pw/svgcontrol/ 主要功能:手动可视化生成 SVG图片PATH路径. 效果如下: 代码如下: <!DOCTYPE html> <!-- ...
- [Swift]LeetCode94. 二叉树的中序遍历 | Binary Tree Inorder Traversal
Given a binary tree, return the inorder traversal of its nodes' values. Example: Input: [1,null,2,3] ...
- [Swift]LeetCode375. 猜数字大小 II | Guess Number Higher or Lower II
We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to gues ...
- [Swift]LeetCode376. 摆动序列 | Wiggle Subsequence
A sequence of numbers is called a wiggle sequence if the differences between successive numbers stri ...
- [SQL]LeetCode601. 体育馆的人流量 | Human Traffic of Stadium
SQL架构 Create table If Not Exists stadium (id int, visit_date DATE NULL, people int) Truncate table s ...
- [Swift]LeetCode994. 腐烂的橘子 | Rotting Oranges
In a given grid, each cell can have one of three values: the value 0 representing an empty cell; the ...