Advertisement
Advertisement


Git refusing to merge unrelated histories on rebase


Question

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. It used to work fine in the previous version.

How can I continue this rebase allowing unrelated histories with the forced flag introduced in the new release?

2019/06/05
1
2257
6/5/2019 11:27:42 AM


In my case, the error was just fatal: refusing to merge unrelated histories on every try, especially the first pull request after remotely adding a Git repository.

Using the --allow-unrelated-histories flag worked with a pull request in this way:

git pull origin branchname --allow-unrelated-histories
2019/06/05

Try the following command:

git pull origin master --allow-unrelated-histories

This should solve your problem.

2019/06/05

I got this error when I set up a local repository first. Then I went to GitHub and created a new repository. Then I ran

git remote add origin <repository url>

When I tried to push or pull, I got the same fatal: unrelated_histories error every time.

Here is how I fixed it:

git pull origin master --allow-unrelated-histories
git merge origin origin/master
... add and commit here...
git push origin master
2019/12/24

For this, enter the command:

git pull origin branchname --allow-unrelated-histories

For example,

git pull origin master --allow-unrelated-histories

Reference:

GitHub unrelated histories issue

2019/06/05

git pull origin <branch> --allow-unrelated-histories

You will be routed to a Vim edit window:

  • Insert commit message
  • Then press Esc (to exit "Insert" mode), then : (colon), then x (small "x") and finally hit Enter to get out of Vim
  • git push --set-upstream origin <branch>
2019/11/28