简体   繁体   English

在git上合并不同的分支

[英]Merging different branches on git

I am working on a team project using git. 我正在使用git进行团队项目。 I created a new branch to write my code. 我创建了一个新分支来编写代码。 My colleagues as well. 我的同事们也是。 I want to integrate the code one of my colleagues developed to my branch without he needs to merge it with the master: Is it possible to merge two branches without merging them to the master? 我想将一位同事开发的代码集成到我的分支中,而无需将其与主代码合并:是否可以合并两个分支而不将其合并到主代码?

master is just some more-or-less random branch as well. master也是一些或多或少的随机分支。 You can merge any branch into any other branch—not just into master. 您可以将任何分支合并到任何其他分支中,而不仅仅是合并到master中。 To do that, check out the target branch and then call git merge on the branch you want to merge in. 为此,请签出目标分支,然后在要合并的分支上调用git merge

So when trying to merge into master, you first check out master using git checkout master and then you merge your branch git merge yourbranch . 因此,当尝试合并到master时,您首先使用git checkout master签出git checkout master ,然后合并分支git merge yourbranch If you want to merge it into that colleague's branch, you check out that first and then merge your branch: 如果要将其合并到该同事的分支机构中,请先将其签出,然后再合并您的分支机构:

git checkout otherbranch
git merge yourbranch

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM