简体   繁体   English

如何针对派生仓库中两个分支之间的差异的上游基础创建拉取请求?

[英]How do I create a pull request against an upstream base that is the difference between two branches in my forked repo?

I forked a repo on GitHub, cloned it locally, made changes, committed them locally and pushed them back to my github repo. 我在GitHub上创建了一个仓库,在本地克隆了它,进行了更改,在本地提交了它们,并将它们推回到了我的github仓库。 I then opened a pull request against upstream for the changes. 然后,我针对上游的更改打开了请求请求。 (That pull request is still outstanding.) (该请求仍未完成。)

Then I created locally created a branch, made some more changes in it, committed them and pushed the new branch to github. 然后,我在本地创建了一个分支,对其进行了更多更改,将其提交,并将新分支推送到github。

How do I open a pull request against the upstream repo for just the changes in my branch? 如何仅针对分支中的更改针对上游仓库打开拉取请求?

I tried creating a pull request naïvely, with base fork == upstream, base branch == master, head fork == my repo, head branch == the new feature branch I created, but the list of diffs includes not only the new changes but all the changes in the still-outstanding pull request I made previously. 我尝试过天真地创建一个拉取请求,其中基础分支==上游,基础分支== master,头分支==我的仓库,头分支==我创建的新功能分支,但差异列表不仅包括新更改但我之前在未完成的请求请求中所做的所有更改。

I then tried creating a pull request with base fork == my repo, base branch == master, head fork == my repo, head branch == feature branch. 然后,我尝试使用基本fork ==我的仓库,基本分支== master,头fork ==我的仓库,head分支==功能分支创建请求请求。 It shows exactly the desired diff, but to be applied to my master, not the upstream master. 它准确显示了所需的差异,但将应用于我的主服务器,而不是上游主服务器。

How do I create a pull request for just the diffs between my master and feature branches, but to be applied to the upstream master? 如何只为我的母版和要素分支之间的差异创建一个拉取请求,然后将其应用于上游母版? Or do I have to wait for the first pull request to be accepted before this is possible? 还是我必须等待第一个请求才能被接受?

I believe that your problem is that the new branch was branched from the old branch. 我相信您的问题是新分支是从旧分支分支出来的。

You could go back to the original branch (master, development?) and create a new branch and then cherry pick or reapply the changes. 您可以回到原始分支(母版,开发版?)并创建一个新分支,然后选择或重新应用更改。 The pull request for the new branch should only contain the 'new' changes. 对新分支的拉取请求应仅包含“新”更改。

You've all the changes in new-branch because you've created this branch from previous branch not from master . 您已经在new-branch所有更改,因为您是从previous branch而不是master创建了这个分支。

$ git log                        # copy commit-sh that have your new changes

$ git checkout master
$ git checkout -b <branch-1>     # checkout a new branch 'branch-1' that has no changes
$ git cherry-pick <commit-sha>   # take the changes into 'branch-1'
$ git push origin HEAD           # push the changes to remote branch-1

Then create a new pull request from your branch-1 . 然后从您的branch-1创建一个新的请求请求。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM