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...

This Post Has One Comment

  1. tyler

    thank you for this!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.