在GitHub中合并叉子 [英] Merging between forks in GitHub

查看:157
本文介绍了在GitHub中合并叉子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我分叉了一个GitHub仓库。然后我对叉子进行了一些更改。然后原始存储库合并我的更改和其他人。现在,我想合并那些我缺少的更改。我尝试了一个简单的拉,然后推,但是这产生了我的承诺一式两份。什么是最好的办法呢?

I forked a GitHub repository. Then I pushed some changes to my fork. Then the original repository merged my changes and some others. Now, I want to merge those changes I'm missing. I tried a simple pull followed by push, but this yield my commits in duplicate. What's the best way to do it?

推荐答案

您可能对每个存储库都有一个远程。您需要从一个遥控器拉到另一个遥控器。

You probably have a "remote" for each repository. You need to pull from the one remote and push to the other.

如果您最初是从您的叉子克隆的,则该遥控器将被称为原点。如果你还没有添加它,你需要添加第一个人的仓库作为另一个远程:

If you originally cloned from your fork, that remote will be called "origin". If you haven't added it already, you'll need to add the first guy's repository as another remote:

git remote add firstguy git://github.com/firstguy/repo.git

在完成所有设置后,您应该确实能够

After that's all set up, you should indeed be able to

git pull firstguy master
git push origin

请记住, git pull 不过是一个宏 git fetch git merge ,按此顺序。你只需要从第一个人的仓库获取提交列表,然后将他的分支合并到你的树中。合并应该在你的两个分支上进行提交。

Remember, git pull is nothing more than a macro that does git fetch and git merge, in that order. You just need to fetch the list of commits from the first guy's repository and then merge his branch in to your tree. Merging should do the right thing with your commits on both branches.

当然,GitHub在它永久的迷人之处给你提供了一个捷径。在仓库的叉子上有一个快进按钮,如果你完全合并到另一端,你可以用它来抓住叉子。

GitHub, in all its perpetual awesomeness, gives you a shortcut, of course. There's a "fast-forward" button on your fork of the repository that you can use to catch your fork up if you're entirely merged in to the other side.

这篇关于在GitHub中合并叉子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆