Git 合并远程分支?

Git 分布式支持的很好,我们可以同时和多个远程库保持联系;既然同时和多库保持联系,那么你就要对多个远程库的同步保持一个敏锐的意识。
虽然看起来很简单的一句话,但对于已经习惯了 svn 这种中心控制型代码管理模式的程序员来说,是有些挑战的;对多线联系感觉困扰的情况,估计和缺乏自治传统的文化或许也有些关系;

应用场景
soho作为一个控制中心,在3和236之间做同步
  • A 可能会提交;
  • B 可能会提交;
  • soho 通常会提交;
有了分叉(diverged)
origin 和 prod 分叉了
  • 产生分叉的机理不明(或许和 rebase 有关?);
  • 希望 origin 和 prod 保持一致;
合并远程分支
git 合并
  • 合并 prod/master
    origin 是通常的源码库,希望将 prod 上的修改合并过来;
  • 做法
git pull prod master
git pull
git merge prod/master
git push
git push prod master:master

或许可以简单地说,将 prod 和 origin 两者上的变化加载到 soho 本地融合起来,然后再分别推送到远程;

You can also explicitly tell git pull what remote branch to pull (as it mentions in the error message):
git pull <remote-name> <remote-branch>, or git pull <repository> <refspec>
Be careful with this, however: if you are on a different branch and do an explicit pull, the refspec you pull will be merged into the branch you're on!
当你这样做的时候,请务必有意识地了解明白这样做带来的后果;

参考
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容