git error: “refusing to merge unrelated histories”

When working with local git repos, whenever I add a remote repo on github and then try to pull down the master from remote to local, I get errors about local repo not being on the same branch as the remote, or more recently this error:

fatal: refusing to merge unrelated histories

I think in the past I’ve done a ‘reset –hard’ like described here, but this didn’t work for me this time, I got the same error about ‘unrelated histories’

Turns out this might be related to a change in git behavior, as described here.

Doing:

git pull github master --allow-unrelated-histories

and then followed with:

git push github master

fixed my issue.

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.