I have a local git repository with already commited code. Now I want to import the repository to github preserving its commits. What I did so far:
I've created a new repository on github.
I've added that as a remote in my local repository:
git remote add origin https://github.com/...
and
git branch --set-upstream-to=origin/master master
But when I try to git pull
I get this error:
fatal: refusing to merge unrelated histories
I've heard of the switch to --allow-unrelated-histories
, but there was a warning this could cause complications to the repository. I didn't try it.
This questions seems to address the same problem, but the answers are very old and do not address the problem I ran into.
Apart from that I found guides that either assume I have another public repository whos URL I could paste to some import dialog; or they assume I have no version control at all, just a bunch of files.