title: How to import local git repository to github?
body: <p>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:</p>
  
  <p>I've created a new repository on github.</p>
  
  <p>I've added that as a remote in my local repository:</p>
  
  <pre><code>git remote add origin https://github.com/...
  </code></pre>
  
  <p>and </p>
  
  <pre><code>git branch --set-upstream-to=origin/master master
  </code></pre>
  
  <p>But when I try to <code>git pull</code> I get this error:</p>
  
  <blockquote>
    <p>fatal: refusing to merge unrelated histories</p>
  </blockquote>
  
  <p>I've heard of the switch to <code>--allow-unrelated-histories</code>, but there was a warning this could cause complications to the repository. I didn't try it.</p>
  
  <p><a href="https://stackoverflow.com/questions/4658606/import-existing-source-code-to-github">This questions</a> seems to address the same problem, but the answers are very old and do not address the problem I ran into.</p>
  
  <p>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.</p>