Solved: Git Refusing to Merge Unrelated Histories

This was just a note for myself because sometimes I start creating a project locally before creating an online repository in Bitbucket. I usually just create a repo in Bitbucket having the .gitignore file added by default.

Run the following git command to add the remote url.

git remote add origin https://[email protected]/OmelSoft/myproject.git

Now, I wanted to merge the histories in the remote repository when it’s initially created to my local repository. To prevent git throwing the error “fatal: refusing to merge unrelated histories“, I used the following command to force the merge to happen.

git pull origin master --allow-unrelated-histories

Cromwell Bayon

He is a self-tutored programmer and a Full-Stack Developer. He strives to excel in the newest technology as possible. He has a very high sense of technicality and analytical skills which allows him to resolve any kind of issues related to technology. He also loves woodworking. Read more about him here...

Add comment

E-mail is already registered on the site. Please use the Login form or enter another.

You entered an incorrect username or password

Sorry, you must be logged in to post a comment.

1 comment

by Newest
by Best by Newest by Oldest
1

thank you for this!