简体   繁体   English

Git 将拉取请求从一个存储库移动到另一个存储库

[英]Git move pull request from one repository to another repository

I have a repository ONE with some work in it.我有一个存储库ONE有一些工作。 There is a open pull request called pull-request which I would like to move with all commits into another repository called TWO .有一个名为pull-request的开放拉pull-request ,我想将所有提交移到另一个名为TWO存储库中。

Repository "ONE" c1_c2_c3_c4_c10_c11_c12_c13...
                            \
     branch "pull-request"   \_c5_c6_c7_c8_c9



Repository "TWO" _____________________________
                                              \
     branch "pull-request-from-repository-ONE" \_c5_c6_c7_c8_c9

Is this possible?这可能吗? If so how?如果是这样怎么办?

Thanks to Steve Bennetts and CodeWizards answers I could get it to work with a mix of both answers like this:多亏了Steve BennettsCodeWizards 的回答,我才能将这两种答案混合使用,如下所示:

in Repository TWO在存储库二

git remote add ONE  https://...
git fetch ONE pull-request

git co -b pull-request-from-repository-ONE
git cherry-pick [sha-commit-hash]

note I messed up with trying to cherry-pick a range of commits, cause my pull-request branch had merges already inside... so anyway, cherry-picking single commits seems to work注意我在尝试挑选一系列提交时搞砸了,因为我的 pull-request 分支已经在里面合并了......所以无论如何,挑选单个提交似乎有效

Assuming this "pull request" is on a service like Github, you just treat it like any other branch, on your computer:假设这个“拉取请求”是在像 Github 这样的服务上,你只需像对待任何其他分支一样对待它,在你的计算机上:

git remote add repoone https://....
git fetch repoone
git merge pull-request

Yes you can but in a workaround:是的,您可以,但有一个解决方法:

Add the 2 remotes to your repository.将 2 个遥控器添加到您的存储库。 then do a git cherry-pick of the desired commit to the second repository and now create a new pull request as usual.然后对第二个存储库执行所需提交的git cherry-pick ,现在像往常一样创建一个新的拉取请求。

The point is that in GIT you can have multiple remotes and the commits can be "added" to any of the branches.关键是在 GIT 中,您可以拥有多个遥控器,并且可以将提交“添加”到任何分支。

If you work with github the pull request are fetched locally to your repository so you can merge them right away.如果您使用 github,拉取请求将在本地获取到您的存储库,以便您可以立即合并它们。


GitHub Checkout github pull requests locally GitHub Checkout 本地 github 拉取请求

https://gist.github.com/piscisaureus/3342247 https://gist.github.com/piscisaureus/3342247

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

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