从别人的叉子合并 Git
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5606048/
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
Git merge from someone else's fork
提问by poundifdef
I have a repository on github, and someone else has forked it and made changes.
我在 github 上有一个存储库,其他人已经对它进行了分叉并进行了更改。
I want to:
我想要:
- Create a new branch
- Merge their changes into my branch
- 创建一个新分支
- 将他们的更改合并到我的分支中
I have created the new branch:
我创建了新分支:
git commit -b my_new_branch
How do I merge their code into this new branch?
我如何将他们的代码合并到这个新分支中?
This is the branch that I have created: https://github.com/poundifdef/VirginMobileMinutesChecker/tree/widget_toast
这是我创建的分支:https: //github.com/poundifdef/VirginMobileMinutesChecker/tree/widget_toast
This is the branch that I want to merge: https://github.com/xbakesx/VirginMobileMinutesChecker
这是我要合并的分支:https: //github.com/xbakesx/VirginMobileMinutesChecker
What is the best way to do this? I've tried a "pull" and it won't work. I honestly have no idea what I'm doing in gitland, so if there is a better way to accomplish this (besides my creating a branch and trying to merge) then I am all ears!
做这个的最好方式是什么?我试过“拉”,但它不起作用。老实说,我不知道我在 gitland 中在做什么,所以如果有更好的方法来实现这一点(除了我创建一个分支并尝试合并),那么我全神贯注!
回答by Ilkka
Add their github fork repo as a remote to a clone of your own repo:
将他们的 github fork 存储库作为远程添加到您自己的存储库的克隆中:
git remote add other-guys-repo <url to other guys repo>
Get their changes:
获取他们的更改:
git fetch other-guys-repo
Checkout the branch where you want to merge:
签出要合并的分支:
git checkout my_new_branch
Merge their changes in (assuming they did their work on the master branch):
合并他们的更改(假设他们在 master 分支上做了他们的工作):
git merge other-guys-repo/master
Resolve conflicts, commit the resolutions and voila.
解决冲突,提交决议,瞧。