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. ionic环境配置

    1.现在 npm install -g ionic 直接安装ionic2版本.用ionic1版本开发,用 npm install -g ionic@1.6. 2.第一次输入: ionic serve ...

  2. 从零开始一起学习SLAM | 为什么要用齐次坐标?

    在涉及到计算机视觉的几何问题中,我们经常看到齐次坐标这个术语.本文介绍一下究竟为什么要用齐次坐标?使用齐次坐标到底有什么好处? 什么是齐次坐标?简单的说:齐次坐标就是在原有坐标上加上一个维度: 使用齐 ...

  3. gitlab数据迁移至其他gitlb服务器上

    需求: A : 待迁移服务器,上边存有数据 B:接收项目得服务器,本身存在数据 验证方案: 一,搭建gitlab8.15.2 OS:rhel7.4 yum install policycoreutil ...

  4. JDBC连接自定义sqlserver数据库实例名(多个实例)

    java语言中,通过jdbc访问sqlserver2005(2008)数据库默认实例可以按常用的写法来写url连接.代码如下: <span style="font-size:12px; ...

  5. 使用sqoop往hdfs中导入数据供hive使用

    sqoop import -fs hdfs://x.x.x.x:8020 -jt local --connect "jdbc:oracle:thin:@x.x.x.x:1521:testdb ...

  6. 2. Python3输入与输出

    数据的输入和输出操作是计算机最基本的操作,本节只研究基本的输入与输出,基本输入是指从键盘上输入数据的操作,基本输出是指屏幕上显示输出结果的操作. 2.1基本输入和输出 常用的输入与输出设备有很多,如摄 ...

  7. html5常用数学 公式的用法

    <script>        // alert(Math.PI);        // alert(Math.floor(3.16));    // var a=Math.ceil(3. ...

  8. Running tests on PyCharm using Robot Framework

    问题: I started using PyCharm with the robot framework, but i'm facing an issue. how can i run my test ...

  9. codeforces 984B Minesweeper

    题意: 给出一个矩阵,如果一个格子是数字,那么与这个格子相邻的格子中有炸弹的数量必须等于这个格子中的数字: 如果一个格子是空地,那么这个格子的所有相邻的格子中就不能有炸弹. 判断这个矩阵是否合法. 思 ...

  10. locust 的使用

    Contents Locust这一款开源性能测试工具.然而,当前在网络上针对Locust的教程极少,不管是中文还是英文,基本都是介绍安装方法和简单的测试案例演示,但对于较复杂测试场景的案例演示却基本没 ...