在 GitHub 中的分叉之间合并 [英] Merging between forks in GitHub

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

问题描述

我创建了一个 GitHub 存储库.然后我对我的叉子进行了一些更改.然后原始存储库合并了我的更改和其他一些更改.现在,我想合并我遗漏的那些更改.我尝试了一个简单的 pull 和 push,但这产生了我的重复提交.最好的方法是什么?

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 one remote and push to the other.

如果您最初是从您的 fork 克隆的,那么该遥控器将被称为origin".如果您还没有添加它,则需要将另一个存储库添加为另一个远程:

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 other repository as another remote:

git remote add <shortname> git://github.com/<ownerName>/repo.git

所有设置完成后,您确实应该可以(github 将默认分支从 master 更改为 main,根据需要进行更改)

After that's all set up, you should indeed be able to (github changed default branch from master to main, change as necessary)

git pull <shortname> master
git push origin

记住,git pull 只不过是一个按顺序执行 git fetchgit 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 other repository and then merge his branch into 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 into the other side.

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

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