Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Bitbucket - Unable to merge Unrelated branches

Tags:

I have repository (lets say A) and forked repository A-dev on Bitbucket. Everything had been worked good for 3 months. But recently, when I tried to create pull request in A-dev it says:

Unable to merge
Unrelated branches

Why this would happen and how it can be solved? How can I troubleshoot it?

Edit

the screenshot of the error

like image 293
user2257338 Avatar asked Apr 08 '13 11:04

user2257338


People also ask

How do I merge unrelated branches in bitbucket?

In fact, all you need to do to merge unrelated branches is to use the flag --allow-unrelated-histories . This tells Git to combine all the files and commits of both unrelated branches into one branch, as long as there are no file conflicts.

How do I fix Git refuses to merge unrelated histories?

The alternative (and longer) way of fixing the fatal: refusing to merge unrelated histories issues is to unstage your current commits, stash them, clone your required remote repository, and then place your stashed branch contents into the new clone.

What is unrelated histories in Git?

The “fatal: refusing to merge unrelated histories” Git error occurs when two unrelated projects are merged (i.e., projects that are not aware of each other's existence and have mismatching commit histories). Consider the following two cases that throw this error: You have cloned a project and, somehow, the .


1 Answers

That means there would be merge conflicts if it attempted to merge. You have to merge in "Repo A" and resolve the conflicts. Then push back up to BitBucket so it can close the pull request. Example workflow:

git remote add repo_a https://url.com/path/to/repo
git fetch repo_a
git merge repo_a/dev
# resolve conflicts
git commit -am "Merge in repo_a/dev and resolved conflicts"
git push origin dev

If you've never dealt with merge conflicts in Git, checkout this SO question.

like image 71
Sam Avatar answered Sep 20 '22 15:09

Sam