用git合并多个分支 [英] Merging multiple branches with git
问题描述
$ git branch -a
* develop
master
遥控器/ origin / HEAD - > origin / master
遥控器/原点/某些测试
遥控器/原点/特性1
遥控器/ origin / feature2
remotes / origin / master
如何合并 remotes / origin / feature1
和 remotes / origin / feature2
放入我的本地master仓库,将其全部复制到develop中,并开始使用我的开发回购?
-
git checkout master $ c $
-
git pull origin feature1 feature2
-
git checkout开发
-
git pull。 master
(或者git rebase ./master
)
第一条命令将当前分支更改为 master
。
feature1
和 feature2
分支。这是一个章鱼合并,因为它合并了两个以上的分支。如果您愿意的话,您也可以进行两次正常的合并。 第三个命令将您切换回您的 develop
分支。
第四个命令将更改从本地 希望有帮助。 master
拉到开发$ c $
git pull
会自动执行 fetch
,所以你不需要手动执行。它几乎等同于 git fetch
,接着是 git merge
。
I have 2 local repositories called "develop" and "master"; they are similar. On my company's server there's 1 "main" repo (production) and several branches that were made by other developers:
$ git branch -a * develop master remotes/origin/HEAD -> origin/master remotes/origin/some-test remotes/origin/feature1 remotes/origin/feature2 remotes/origin/master
How can I merge remotes/origin/feature1
and remotes/origin/feature2
into my local "master" repo, copy that all into "develop" and start working with actual code in my "develop" repo?
git checkout master
git pull origin feature1 feature2
git checkout develop
git pull . master
(or maybegit rebase ./master
)
The first command changes your current branch to master
.
The second command pulls in changes from the remote feature1
and feature2
branches. This is an "octopus" merge because it merges more than 2 branches. You could also do two normal merges if you prefer.
The third command switches you back to your develop
branch.
The fourth command pulls the changes from local master
to develop
.
Hope that helps.
EDIT: Note that git pull
will automatically do a fetch
so you don't need to do it manually. It's pretty much equivalent to git fetch
followed by git merge
.
这篇关于用git合并多个分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!