Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to merge two branches

KC-JR
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 4, 2021

Hi Team,

We are trying to merge two branches in a repository, where we are getting below issue.

Git failed with a fatal error.
Git failed with a fatal error.
fatal: refusing to merge unrelated histories.

The scenario is 

We have two repositories kcapp and kcresourceplanning, taken a branch from kcapp and moved to kcresourceplanning. where we already have some branches over there.

But when we are trying merge the branches we are getting above issue.

Can you please look into this and help us.

1 answer

0 votes
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 6, 2021

Hi @KC-JR and welcome to the community.

By default, git merge command refuses to merge histories that do not share a common ancestor. If you take a branch from one repository and move it to another repository that is not a fork, this branch will not have a common ancestor with any branch of the repo where you moved it.

It is possible to override this behavior by using the option --allow-unrelated-histories in the git merge command. You will need to do the merge locally with a command like the following, and then push to Bitbucket:

git merge <branch_name> --allow-unrelated-histories

You can find more info about this option on the git merge documentation page, if you search for the option --allow-unrelated-histories:

If you have any questions, please feel free to let me know.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events