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. 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?
CodePudding user response:
It is possible to make a pull-request equivalent of git merge --allow-unrelated-histories
. You can do it like so:
# First, create a new branch based on master:
git switch -c history-merge master
# Next, merge your branch with the unrelated history into `history-merge`
#
# You named this branch `pull`, but I've renamed it to
# `unrelated` for the sake of example.
#
# Resolve any merge conflicts at this time,
# and change the merge text to "Merge branch 'unrelated' into master".
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 master
. If you want it to be 100% seamless, choose the rebase
option when you go to merge the PR. This will fast-forward master
to the original merge-commit.