当原始主分支无法合并时,是否有一个与原始存储库相匹配的分叉?
SO 为我提供的相关问题仅回答可以通过拉动解决的简单情况 - 但是,这效果不佳,如下所示。
我分叉了一个存储库,只有一个 master
分支,我已经分叉了它,并且我在我的 master
和一个新分支中工作我自己的,rw-style
。分叉存储库的所有者提交了我的一些更改,但没有提交其他更改;下面右上角的黑点代表来自我的 master
和 rw-style
分支的提交。
我知道使用 fork 队列不是一个好主意,所以我远离它。使用 git pull 确实有效,但它会产生一个我需要解决的冲突,并且还会导致我的 master 分支出现重复的历史记录,而这并不会看起来特别漂亮。
我现在不知道任何其他解决方案,所以我目前正在考虑从我尚未推送的两个提交创建一个补丁,删除我的分叉,从原始版本再次创建它,然后在上面应用我的补丁它的。
这是唯一的解决方案吗?
The related questions that SO offer me only answer simple cases that can be solved with a pull - however, that doesn't work well, as you'll see below.
There's a repository I've forked, with just a master
branch, and I've forked it, and I've worked in both my master
, and a new branch of my own, rw-style
. The owner of the forked repository's committed some of my changes but not others; the black dots on the top right below represent commits from both my master
and rw-style
branches.
I'm aware using the fork queue is not a good idea, so I'm staying away from it. Using git pull
does work, but it creates a conflict that I would then need to resolve, and it also results in duplicate history for my master
branch, and that doesn't look particularly pretty.
I don't know any other solutions right now, so I'm currently considering just creating a patch from two commits that I haven't yet pushed, deleting my fork, creating it again from the original, and then applying my patches on top of it.
Is that the only solution?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以通过以下方式将您的 fork 重新设置为 master:(
在 fork 分支中时)。或者,您也可以将 --hard 您的 fork 分支重置为 master 分支,然后从您的 fork 分支中挑选每个提交(但是 rebase 的工作量将大大减少,除非您只被几个提交分叉)。
完成此操作后,您应该能够将分叉分支合并到主分支上,作为快进合并(没有合并提交或任何内容)。但是,执行上述任一操作都会弄乱 fork 分支中的所有哈希值,因此除非您确定没有其他东西引用该 fork 分支,否则不要这样做。
You can rebase your fork on to master, via:
(while in the fork branch). Alternatively you could also reset --hard your fork branch to your master branch, then cherry-pick every commit from your fork branch back in (but the rebase will be wayyy less work unless you're only forked by a few commits).
Once you've done that, you should be able to just merge your forked branch on to the master branch, as a fast-forward merge (no merge commits or anything). However, doing either of the above will mess up all of your hashes in your fork branch, so don't do this unless you're sure nothing else is referencing the fork branch.