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.


git pull github master --allow-unrelated-histories

and then followed with:

git push github master

fixed my issue.

Git notes (3) – tagging

To tag all files at a current point in time (e.g. to track a release), use:

git tag -a tagname -m "tag description"

To view current tags:

git tag

To show commits associated with a tag:

git show tagname

To push a tag to a remote repo:

git push remotename tagname