title: How to push code on my local machine to GitHub in the main branch
body: <p>I have created a Repository as the default main branch.</p>
  <p>Step I tried to add to the repository:</p>
  <ol>
  <li>git config --global init.befaultBranch main</li>
  <li>git init -b main</li>
  <li>git add .</li>
  <li>git commit -m &quot;commit to main branch&quot;</li>
  <li>git remote add origin '<strong>my git url</strong>'</li>
  </ol>
  <p>Now I have stuck to push to the <strong>origin</strong></p>
  <p>I have tried <code>git push -u origin main</code> but it gave me an error as:</p>
  <blockquote>
  <p>! [rejected]        main -&gt; main (fetch first)
  error: failed to push some refs to 'my git url'</p>
  </blockquote>
  <p>How to push the code from my local machine to GitHub in the <strong>main</strong> branch?</p>
  <p>Any help and pointing to the documentation will be appreciated.</p>
  <p>I tried to pull first and there is also an error on doing that:</p>
  <pre><code>$ git pull origin main
  </code></pre>
  <blockquote>
  <p>From <code>my git url</code>  * branch<br />
  main       -&gt; FETCH_HEAD fatal: refusing to merge unrelated histories</p>
  </blockquote>