git 如何将另一个开发者的分支合并到我的分支中?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11582894/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:10:56  来源:igfitidea点击:

How do I merge another developer's branch into mine?

gitversion-controlgithub

提问by Ryan Kohn

I am relatively new to git. Our organization uses a Fork & Pull Modelfor managing changes to the master branch. Each developer forks the master and branches from their fork when adding new features. I keep an eye on commits that other developers are making in their own branches, and would sometimes like to merge these changes into my own branch. What steps do I take to accomplish this?

我对 git 比较陌生。我们的组织使用Fork & Pull 模型来管理对 master 分支的更改。每个开发人员在添加新功能时从他们的分支中分叉主分支和分支。我密切关注其他开发人员在他们自己的分支中所做的提交,有时希望将这些更改合并到我自己的分支中。我需要采取哪些步骤来实现这一目标?

回答by Christoph

You first need to add the other developer repository as a remote.

您首先需要将其他开发人员存储库添加为远程。

git remote add otherrep uriToOtherRep

Then you fetch changes from there

然后你从那里获取更改

git fetch otherrep

And then you merge the branch from the remote repository into yours

然后您将远程存储库中的分支合并到您的分支中

git merge otherrep/branchname

Happy merging!

快乐合并!

回答by Ryan Kohn

You can also do "git pull", it'll pull the changes of all the branches.

你也可以做“git pull”,它会拉取所有分支的变化。

git pull

You can run git merge into your current branch

您可以在当前分支中运行 git merge

git merge origin/<branchname>

合并 origin/<branchname>

回答by Michael Krelin - hacker

once you have the branch in question in your repository as, say, anotherdev/masterremote branch, you do the git merge anotherdev/master.

一旦您的存储库中有相关分支,例如anotherdev/master远程分支,您就可以执行git merge anotherdev/master.