git 两个repo merge

You can't merge a repository into a branch. You can merge a branch from another repository into a branch in your local repository. Assuming that you have two repositories, foo and bar both located in your current directory:

$ ls
foo bar

Change into the foo repository:

$ cd foo

Add the bar repository as a remote branch and fetch it:

$ git remote add bar ../bar
$ git remote update

Create a new branch baz in the foo repository based on whatever your current branch is:

$ git checkout -b baz

Updated with "real-life" commands:

Start from your repo directory, make sure your working copy is clean (no files changed, added or removed).


Make a new branch:

git checkout -b <my-branch>

Add the secondary remote, then fetch it:

git remote add <repo-name> git@github.com:xxx/<repo-name>.git
git remote update

Merge one of their branches in your current branch:

git-merge <repo-name>/<their-branch>


If you don't know which <their-branch> you want, then go for master

If you are sure you want to accept all remote changes and avoid conflicts (overwrite yours) then you can specify -X theirs as option for git merge in the last step.

If you want to add it in a subdirectory then probably you should probably use git submodules

Merge branch somebranch from the bar repository into the current branch:

$ git merge bar/somebranch

Merge git repo into branch of another repo的更多相关文章

  1. git pull的时候提示git pull <remote> <branch>

    yuanqiao@yuanqiao-PC MINGW64 /h/WorkSpace/git/dadeTest (dev)$ git pullremote: Enumerating objects: 7 ...

  2. git merge & git rebase

    git merge & git rebase bug error: You have not concluded your merge (MERGE_HEAD exists). hint: P ...

  3. spark mllib配置pom.xml错误 Multiple markers at this line Could not transfer artifact net.sf.opencsv:opencsv:jar:2.3 from/to central (https://repo.maven.apache.org/maven2): repo.maven.apache.org

    刚刚spark mllib,在maven repository网站http://mvnrepository.com/中查询mllib后得到相关库的最新dependence为: <dependen ...

  4. git clone all branch and create a empty branch

    /******************************************************************** * git clone all branch and cre ...

  5. git clone指定branch或tag

    git clone指定branch或tag发布时间:October 28, 2018 // 分类: // No Comments 取完整: git clone https://github.com/a ...

  6. Git Step by Step – (2) 本地Repo

    前面一篇文章简单介绍了Git,并前在Windows平台上搭建了Git环境,现在就正式的Git使用了. Git基本概念 在开始Git的使用之前,需要先介绍一些概念,通过这些概念对Git有些基本的认识,这 ...

  7. Git: untrack a file in local repo only and keep it in the remote repo

    You could update your index: git update-index --assume-unchanged nbproject/project.properties and ma ...

  8. git merge 到 非当前 branch

    1. Add a remote alias for your local repository, ex: git remote add self file:///path/to/your/reposi ...

  9. git学习之branch分支

    作为新手,站在我的角度肤浅的来理解,分支就是相当于开辟了一个新的临时工作区,在这个工作区进行文件代码改动,然后在合并到master主工作区,这样能保证主工作区的安全性和稳定性,对于团队协作尤为重要. ...

随机推荐

  1. 前端基础进阶(五):全方位解读this

    https://segmentfault.com/a/1190000012646488  https://yangbo5207.github.io/wutongluo/ 说明:此处只是记录阅读前端基础 ...

  2. python路径相关操作

    #获取当前文件所在目录filedir = __file__ print os.path.dirname(filedir) #获取文件名print os.path.basename(filedir)

  3. cocos2d JS-(JavaScript) 函数类型相互转换(字符串、整形、浮点形、布尔值)

    工作忙好些天了,近段时间抽点空分享一下自己学习JS的一点笔记心得做点记录,大神勿喷,谢谢! 1.字符串的转化 var found = false; console.log(found.toString ...

  4. RCNN系列算法的发展

    一. RCNN系列的发展 1.1  R-CNN 根据以往进行目标检测的方法,在深度学习应用于目标检测时,同样首先尝试使用滑动窗口的想法,先对图片进行选取2000个候选区域,分别对这些区域进行提取特征以 ...

  5. php背景图片上生成二维码,二维码上带logo 代码示例 (原)

    依赖库文件 phpqrcode.php (下载地址://www.jb51.net/codes/189897.html :或者在官网下载:http://phpqrcode.sourceforge.net ...

  6. linux临时网络配置

    1.设置IP地址: ifconfig ens33 192.168.60.231/24 2.添加默认网关路由 $Route add default gw <默认网关地址> 例:#route ...

  7. 获取PC硬件硬件序列号,唯一标识一台PC

    用一个库:jydisk.dll  百度说是windows提供的C++标准动态库,很方便使用. 点击连接下载文件,里面有各种语言的调用例子,可直接使用.测试多台机器,结果靠谱.没有遇到获取出来是全零的情 ...

  8. 关于c语言中的program_invocation_short_name

    错误源自用g++的交叉编译工具链编译eudev.经过一番查找,发现在 errno.h 这个头文件中有 program_invocation_short_name 的 extern 定义. 经过查看 e ...

  9. python多版本控制

    1安装git # yum install git -y 2.安装python依赖 # yum -y install gcc make patch gdbm-devel openssl-devel sq ...

  10. SnmpTools配置

    上网搜索了很多文档,但是snmptools一直没有配置好,原因就是64机器,网上的说法大多直接复制过来的,或者就没有考虑64位机器.经过仔细搜索和测试,一下是详细的配置过程: Index 安装 如果是 ...