将上游分支的合并请求合并到派生存储库中 [英] Merge Pull Request from Upstream Branch into a Forked Repository

查看:228
本文介绍了将上游分支的合并请求合并到派生存储库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是git的新手,所以请原谅我使用术语所犯的任何错误.

I'm new to git, so forgive me for any mistakes I make with my terminology.

我有一个分叉的仓库.在原始回购中,有人发出包含多个不同提交的请求请求.然后,该拉取请求将合并到原点中.我也希望该拉取请求,因此我也希望将其合并到我的回购中.正确的做法是什么?我尝试挑剔每个提交,但都行得通,但是我觉得那不是完成事情的正确方法.

I have a forked repo. In the origin repo, someone makes a pull request containing a bunch of different commits. That pull request is then merged into the origin. I would also like that pull request, so I want it merged into my repo too. What's the correct way of doing this? I tried cherry-picking each commit, and that worked, but I feel like that isn't the right way to get things done.

我将尝试更详细地说明正在发生的事情和我想做什么的确切结构.

I'll attempt to more specific about exact structure of what's happening and what I want to do.

有一个原始存储库,我们称为A.

There is the original repo we'll call A.

一组开发人员将该存储库分叉到一个我们称为B的几乎单独的项目中.

A group of developers forked that repo into a mostly separate project that we'll call B.

我分叉了B,以便我可以创建自己的分支并为请求请求做出贡献,这就是仓库C.

I forked B so that I could create my own branches and contribute with pull requests, this is repo C.

通过拉取请求对仓库A进行了更改.此PR是在创建B的分支之后进行的,我们希望在存储库B中获得A的PR的提交.

There's a change to repo A through a pull request. This PR was made after the fork that created B, and we want the commits from A's PR in repo B.

为了将其添加到B,我需要执行与A相同的合并,然后在我的仓库C上进行合并,然后通过更改向B发出请求请求.

In order to add it to B, I need to do the same merge they did to A, and do it on my repo C, then make a pull request for B with the changes.

现在,我没有从A合并PR提交到C,而是从Cherry从PR中选择了提交并按顺序应用它们.这行得通,但是我觉得这不是做事情的最佳方法.

Right now, rather than merge the PR commits from A into C, I instead just cherry picked the commits from the PR and applied them in order. This worked, but I don't feel like this is the best way to do things.

推荐答案

  1. 在分支上签出您希望合并到的分支.通常你 将合并为主控.

  1. Check out the branch you wish to merge to on your fork. Usually, you will merge into master.

git checkout master

从上游存储库中拉出所需的分支.这个方法 将保留提交历史记录而无需修改.

Pull the desired branch from the upstream repository. This method will retain the commit history without modification.

git pull https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git BRANCH_NAME

如果存在冲突,请解决它们.有关更多信息,请参见 解决合并冲突".

If there are conflicts, resolve them. For more information, see "Addressing merge conflicts".

提交合并.

将合并推送到您的GitHub存储库中.

Push the merge to your GitHub repository.

git push origin master

这篇关于将上游分支的合并请求合并到派生存储库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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