简体   繁体   English

根据上游而不是基于我的上游分叉创建git分支

[英]Making a git branch based on upstream, not on my ahead-of-upstream fork

I have a fork, which I update from the upstream repo on GitHub fairly regularly. 我有一个fork,我从GitHub的上游仓库定期更新它。 I use this in my project, so it naturally has all the branches I've created merged in so that I can make use of the fixes I need. 我在项目中使用了它,因此自然会将我创建的所有分支都合并到其中,以便可以利用所需的修复程序。

However, the original repo does not necessarily take my pull requests right away. 但是,原始回购并不一定会立即接受我的请求。 So, when I want to make a new pull request, without including the outstanding PRs, how can I fork the original repo again to make changes based on it, rather than my fork, so I can submit new, unrelated PRs? 因此,当我要发出新的请求而不包括未完成的PR时,如何才能再次派生原始存储库而不是基于我的派生来基于它进行更改,以便我可以提交新的,不相关的PR?

Currently what I've been doing is making a branch of my fork, then rebasing it back to before the oldest outstanding PR, then picking everything besides the outstanding PRs. 目前,我一直在做一个分支,然后将其重新部署到最旧的未完成PR之前,然后选择未完成PR之外的所有内容。 This is fine on a small scale, but now that there are some outstanding PRs several weeks and hundreds of commits ago, it's quite a pain, just to submit a small change to upstream. 从小规模上来看这很好,但是现在已经有几周了,并且有数百个提交,所以现在还存在一些出色的PR,这是很痛苦的,只是向上游提交一个小的更改。

IOW I want a branch based on the current upstream, not on my current fork, which is ahead of upstream. IOW我希望基于当前上游的分支,而不是基于当前分支的分支,该分支位于上游。 How can I get this easily in GitHub? 我如何在GitHub上轻松获得它?

I guess I had trouble seeing it in the moment. 我想我现在很难看。 I had considered @RuslanOsmanov's answer already, but couldn't see how to get there from my current situation. 我已经考虑过@RuslanOsmanov的答案,但无法从当前的情况看如何达到目标。 I guess I should have done things differently from the start, and for that situation, there's always...rebase! 我想我应该从一开始就做不同的事情,在这种情况下,总会有...变基! So I do one last rebase, this time on my fork, and after that keep my own branch with my combined PRs, and leave the fork to just pull from upstream. 因此,我最后一次进行了基础调整,这一次是在分支上进行的,之后,将合并的PR保留在自己的分支中,然后将分支从上游拉出。

This is a bit less than intuitive to me, thinking in terms of how "real" forks would contribute back to upstream, but if that's the only way to do it, so be it. 对于我来说,这有点不直观,只是考虑“真正的”分支将如何影响上游。但是,如果这是唯一的方法,那就这样吧。

However, trying to rebase this way gave me the obscure error Unrecoverable error: Merge commit parent missing in TortoiseGit. 但是,尝试以这种方式重新设置基准给了我一个晦涩的错误Unrecoverable error: Merge commit parent missing TortoiseGit中Unrecoverable error: Merge commit parent missing In this case, the fix was skipping the commit in question, which was just a "catch up" merge anyway; 在这种情况下,解决方案是跳过有问题的提交,无论如何,这仅仅是“追赶”合并。 oddly some other catch up merges did not cause problems. 奇怪的是,其他一些追赶合并并未引起问题。

Actually much easier than rebase was a reset HEAD to an old revision, then making a reverse PR to catch up. 实际上,将HEAD重置为旧版本比重新设置基础要容易得多,然后进行反向PR赶上来。 From there I was ready with a not-ahead-of-upstream fork. 从那里,我已经准备好了没有上游的分叉。

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

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