gpt4 book ai didi

git - 将 git repo merge 到另一个 repo 的分支

转载 作者:IT王子 更新时间:2023-10-29 00:32:08 69 4
gpt4 key购买 nike

给定 repo Foo 和 repo Bar。我想将 Bar 与 Foo merge ,但是仅 merge 到一个单独的分支中,称为 baz

git switch -c baz <= 把 Bar 仓库放在这里。

最佳答案

您不能将存储库 merge 到分支 中。您可以将另一个存储库中的分支 merge 到本地存储库中的分支。假设您有两个存储库,foobar 都位于您的当前目录中:

$ ls
foo bar

进入foo 仓库:

$ cd foo

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

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

根据您当前的分支在foo 存储库中创建一个新分支baz:

$ git switch -c baz

bar 仓库中的分支 somebranch merge 到当前分支:

$ git merge --allow-unrelated-histories bar/somebranch

(--allow-unrelated-histories 在 git 2.9 版本之前不需要)

关于git - 将 git repo merge 到另一个 repo 的分支,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21353656/

69 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com