fatal refusing to merge unrelated histories
fatal refusing to merge unrelated histories Photo by Yancy Min on Unsplash

“fatal: refusing to merge unrelated histories” Git Error

Have you ever came across this git error “fatal: refusing to merge unrelated histories”. If yes then this article is especially for you.

fatal: refusing to merge unrelated histories
fatal: refusing to merge unrelated histories

I got this error by doing following

  1. I created a Laravel project in my local.
  2. Also, at the same time, I created a new repo on my GitHub account.
  3. Then to track the project in GitHub I simply did the following :
git initialized and added remote origin
git initialised and added remote origin

4. and committed the changes on my local.

git local changes committed
git local changes committed

Now, it was time to push the changes back to my remote repo. So, I simply tried to pull the changes from my remote repo, and this error occurred.

fatal: refusing to merge unrelated histories

You would have understood the cause.

Yes, it was because even though I had added the remote origin on my working folder locally, my local and remote project is not related as they both were created independently and they both have no common base, which is why they both don’t know each other’s state. And therefore the error “fatal: refusing to merge unrelated histories”.

So, whenever you are in a situation like this where you local git repo is not related to your remote git repo and still you want to sync or push your changes across remote repo, you can do this

git pull origin master --allow-unrelated-histories

More on this at Git official documentation

About the author

Rohan Kamble

A Web Developer by profession, who loves the web to the core with over 9 Years of Experience working on a wide range of domains like websites on e-commerce, Travel, Alumni, matrimonial, company's professional sites, Finance, company internal communications and many more. Also WordPress Plugins & Chrome extensions.

View all posts

Leave a Reply

Your email address will not be published. Required fields are marked *

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