在拉取请求中仅包含特定的提交

问题描述:

假设我已经克隆了存储库,创建了新分支Topic1",进行了更改,提交了它们,然后将它们推送到远程存储库 git push origin Topic1.之后,我向 master 分支发出了拉取请求.

Let's say I have cloned repository, created new branch "Topic1", made changes, commited them and then pushed them to a remote repo git push origin Topic1. After that I made a pull request into master branch.

然后在我的本地存储库中,我从分支Topic1"签出到分支Topic2",在那里进行了一些更改,提交并再次将这个新分支推送到远程.并再次向 master 发出拉取请求.我想提一下,在此期间没有对 master 分支进行任何更改,因此我不需要将我的本地 repo 与上游同步.

Then on my local repository I checkout from branch "Topic1" to branch "Topic2", made some changes there, commited and again pushed this new branch to remote. And again made a pull request into master. I want to mention that in the meantime no changes were made to master branch, so I didn't need to sync my local repo with upstream.

问题是:当我转到Topic2"的拉取请求页面时,Topic1"的所有提交都显示在那里.所以,我的问题 - 我怎样才能获得仅与Topic2"分支相关的第二个拉取请求提交?

And here's the problem: when I go to pull request page of "Topic2" all the commits of "Topic1" are presented there. So, my question - how can I get in 2nd pull request commits related only to "Topic2" branch?

  1. 基于upstream/master

樱桃挑选 来自您分支的相关提交 Topic2(进入新分支)

cherry-pick the relevant commits from your branch Topic2 (into the new branch)

从这个新分支创建拉取请求.

Create a pull request from this new branch.