将git repo合并到另一个repo的分支中 [英] Merge git repo into branch of another repo

查看:266
本文介绍了将git repo合并到另一个repo的分支中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

给予回购美孚和回购吧。我想将Bar与Foo,合并到一个名为 baz 的独立分支中。



git checkout -b baz < =将Bar回购放在这里。

解决方案

您无法将存储库合并到分支中。您可以将本地存储库中另一个存储库的分支合并到分支中。假设您有两个存储库, foo bar 都位于您当前的目录中:

  $ ls 
foo bar

更改为 foo 存储库:

  $ cd foo 

存储库添加为远程分支并获取它:

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

中创建一个新分支 baz foo 存储库基于您当前的分支是什么:

  $ git checkout -b baz 

合并分支 somebranch bar 资源库到当前分支:

  $ git merge bar / somebranch 
code>


Given repo Foo and repo Bar. I want to merge Bar with Foo, but only into a separate branch, called baz.

git checkout -b baz <= put the Bar repo here.

解决方案

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

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

$ git merge bar/somebranch

这篇关于将git repo合并到另一个repo的分支中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆