 <p>This sequence of commands clones your GitHub repository (or any other repository if you change the URL) to <code>~/local-repos</code>, initializes an empty repository in <code>~/remote-repos.git</code> and pushes from <code>~/local-repos</code> to <code>~/remote-repos.git</code> all branches.</p> <pre><code>git clone 'https://github.com/nhnc-nginx/apache2nginx' ~/local-repos git init --bare ~/remote-repos.git cd ~/local-repos git remote add mirror-server ~/remote-repos.git git push --mirror mirror-server </code></pre> <p>Later you update tracking branches (and get new ones) in your <code>~/local-repos</code> with <code>git fetch origin</code> executed inside <code>~/local-repos</code>. You can mirror everything to <code>~/remote-repos.git</code> again with <a href="https://www.kernel.org/pub/software/scm/git/docs/git-push.html" rel="nofollow"><code>git push --mirror mirror-server</code></a>. If you want to push a single branch (e.g. <code>origin/gh-pages</code>), use <code>git push mirror-server origin/gh-pages</code>.</p> <p>Notice that <code>https://github.com/nhnc-nginx/apache2nginx</code> remote is named <code>origin</code> automatically. <code>git fetch origin</code> fetches accessible objects from <code>origin</code> repository and stores branches as tracking branches. Tracking branches are prefixed with the remote name (<code>origin</code> in this case). If you perform <code>git checkout gh-pages</code> and no <code>gh-pages</code> branch exists, Git performs <code>git branch --track gh-pages origin/gh-pages</code> before performing the checkout, which creates the <code>gh-pages</code> branch with upstream set to <code>origin/gh-pages</code>.</p> <p>This was probably the source of the errors your Git reported. You fetched just <code>origin/gh-pages</code> and tried to push non-existent <code>gh-pages</code> branch. As part of checkout, <code>gh-pages</code> was created, so push work then.</p> <p>Also notice that you are creating a mirror of your local repository, not <code>origin</code>. If you want to mirror your GitHub repository, you should execute <code>git fetch origin</code> inside the just created empty mirror with <code>git remote add origin 'https://github.com/nhnc-nginx/apache2nginx'</code>.</p>