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

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.

Join our list

Subscribe to our mailing list and get interesting stuff and updates to your email inbox.

Thank you for subscribing.

Something went wrong.