git 在拉取请求中只包含特定的提交
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/14034718/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Include only specific commits in a pull request
提问by tokenvolt
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”,进行了更改,提交了它们,然后将它们推送到远程 repo git push origin Topic1
。之后,我向 master 分支发出了拉取请求。
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.
然后在我的本地存储库中,我从分支“Topic1”签出到分支“Topic2”,在那里进行了一些更改,提交并再次将这个新分支推送到远程。并再次向 master 发出拉取请求。我想提一下,在此期间没有对 master 分支进行任何更改,因此我不需要将我的本地 repo 与上游同步。
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?
这就是问题所在:当我转到“Topic2”的拉取请求页面时,“Topic1”的所有提交都出现在那里。所以,我的问题 - 我怎样才能获得仅与“Topic2”分支相关的第二个拉取请求提交?
回答by Peter
Create a new branch based on
upstream/master
cherry-pickthe relevant commits from your branch Topic2(into the new branch)
Create a pull request from this new branch.
创建一个新的分支基于
upstream/master
从您的分支Topic2 中挑选相关提交(进入新分支)
从这个新分支创建一个拉取请求。