During git rebase origin/development
the following error message is shown from Git:
fatal: refusing to merge unrelated histories
Error redoing m
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
:
$ git rebase origin/development
fatal: refusing to merge unrelated histories
Error redoing merge 1234deadbeef1234deadbeef
This error doesn't actually cancel the rebase, but you are now in the middle of it:
$ git status
interactive rebase in progress; onto 4321beefdead
Last command done (1 command done):
pick 1234deadbeef1234deadbeef test merge commit
So you can now do the merge by hand. Find out the parent commits of the original merge commit:
$ git log -1 1234deadbeef1234deadbeef
commit 1234deadbeef1234deadbeef
Merge: 111111111 222222222
Author: Hans Dampf
Date: Wed Jun 6 18:04:35 2018 +0200
test 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:
$ git merge --allow-unrelated 222222222 --no-commit
Automatic merge went well; stopped before committing as requested
$ git commit -C 1234deadbeef1234deadbeef
[detached HEAD 909af09ec] test merge commit
Date: Wed Jun 6 18:04:35 2018 +0200
$ git rebase --continue
Successfully rebased and updated refs/heads/test-branch.