[英]How can I create a pull request between branches with entirely different commit histories
I have two branches with entirely different commit histories, and I need to create a pull request - NOT MERGE - from one of them to the other.我有两个具有完全不同的提交历史的分支,我需要创建一个拉取请求- 不是 MERGE -从其中一个到另一个。 When I tried it gave me this:当我尝试时,它给了我这个:
I tried to push a mutual commit, but this is not working.我试图推动相互提交,但这不起作用。 What is the best practice for it?它的最佳实践是什么? I'm a beginner and this is my first time dealing with it.我是初学者,这是我第一次处理它。
What should I do to create this pull request with all files contained in the pull
branch?我应该如何使用pull
分支中包含的所有文件创建此 pull request?
It is possible to make a pull-request equivalent of git merge --allow-unrelated-histories
.可以发出等同于git merge --allow-unrelated-histories
的拉取请求。 You can do it like so:你可以这样做:
# First, create a new branch based on main:
git switch -c history-merge main
# Next, merge your branch with the unrelated history into `history-merge`
#
# Resolve any merge conflicts at this time,
# and change the merge text to "Merge branch 'unrelated' into main".
git merge unrelated --allow-unrelated-histories
# Push your new branch:
git push -u origin history-merge
Once that's done, you can create a pull request from history-merge
into main
.完成后,您可以创建一个从history-merge
到main
的拉取请求。
If you want it to be 100% seamless, choose the rebase
option when you go to merge the PR.如果你希望它是 100% 无缝的,请在 go 合并 PR 时选择rebase
选项。 This will fast-forward main
to the original merge-commit.这会将main
快进到原始的合并提交。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.