Sign in
Log inSign up

Git Extensions Branch Merge with Allow unrelated histories Option

Jakov Pavlek's photo
Jakov Pavlek
·May 8, 2020

Use-Case Scenario

So this would be a use-case scenario: you are working on a private project in your spare time and for some reason have a sharp deadline, possibly with an NDA. You setup the project locally on your machine, and using Git Extensions for version control. What you are missing is possibly a remote repository for backup. You can't publish it publicly on Github, so you might want to be using BitBucket for instance. You create a remote repository online and want to merge it with your already existing git repository locally.

The Problem

After selecting Merge in Merge branches dialog window and passing Git authentication, you get "fatal: refusing to merge unrelated histories” Git error message in a pop-up window, which is set as the default behavior. The problem could be frustrating, but the solution is simple.

The Solution

The solution is just 3 clicks away...

MergeBranches-AllowUnrelatedHistories.png

The 1st click: ☑ Show advanced options

The 2nd click: ☑ Allow unrelated histories

The 3rd click: Merge

That's it. Done. The merge should now be successful.

Discussion

If you are using pure Git in command line or Git with some GUI other than Git Extensions, you might solve the problem manually by typing in merge command:

git merge origin master --allow-unrelated-histories

Links:

The “fatal: refusing to merge unrelated histories” Git error