During git rebase origin/development
the following error message is shown from git:
fatal: refusing to merge unrelated histories
Error redoing merge 1234deadbeef1234deadbeef
My git version is 2.9.0. Used to work fine in previous version.
How can I continue this rebase allowing unrelated histories with the forced flag introduced in the new release?
Try
git pull --rebase development
For this, enter the command as:-
Ex:- git pull origin master --allow-unrelated-histories
Reference:- Github unrelated histories issue
In my case, error was just
fatal: refusing to merge unrelated histories
on every especially first pull request after remotely adding a git repo.Using
--allow-unrelated-histories
flag worked with pull request in this way:git pull origin branchname --allow-unrelated-histories
The default behavior has changed since git 2.9:
See the git release changelog for more information.
You can use
--allow-unrelated-histories
to force the merge to happen.Since all the other answers are not actually answering the question, here is a solution inspired by this answer on a related question.
So you get your error doing git rebase:
This error doesn't actually cancel the rebase, but you are now in the middle of it:
So you can now do the merge by hand. Find out the parent commits of the original merge commit:
Find out which of the two merge parents is the one that was merged into the current one (probably the second one, verify with
git log 222222222
), and then do the merge by hand, copying the commit message of the original merge commit:I got this error when I set up a local repository first. Then went to github and created a new repository. Then I ran
When I tried to push/pull, I got the same
fatal: unrelated_histories
error. Here is how I fixed it: