title: Creating new repository out of old one and saving the log history
body: <p>I have some repository X. I would like to create a new empty repository that contains all of the files of X and the commit history as well.
  I have created a new repository remotely. I cloned the old repository X and I ran the following commands (I work with gitflow):</p>
  
  <pre><code>git flow init
  git remote set-url origin $URL
  git remote -u # Just to check
  git push -u origin master
  </code></pre>
  
  <p>The last command failed with the following error:</p>
  
  <pre><code>To $URL
   ! [rejected]        master -&gt; master (fetch first)
  error: failed to push some refs to '$URL'
  hint: Updates were rejected because the remote contains work that you do
  hint: not have locally. This is usually caused by another repository pushing
  hint: to the same ref. You may want to first merge the remote changes (e.g.,
  hint: 'git pull') before pushing again.
  hint: See the 'Note about fast-forwards' in 'git push --help' for details.
  </code></pre>
  
  <p>The new remote repository is empty and does not have any files. It also has only master branch.
  What am I doing wrong?</p>
  
  <p><strong>Edit:</strong> I ran the following command:</p>
  
  <pre><code>git push --force -u origin master
  </code></pre>
  
  <p>The result:</p>
  
  <pre><code>Counting objects: 3751, done.
  Delta compression using up to 36 threads.
  Compressing objects: 100% (1131/1131), done.
  Writing objects: 100% (3751/3751), 577.15 KiB | 322 KiB/s, done.
  Total 3751 (delta 2615), reused 3727 (delta 2605)
  error: unpack failed: error zeroPaddedFilemode: object a8025c7657985de77312ba1eea3dd926d50eae2f: mode starts with '0'
  fatal: Unpack error, check server log
  To $URL
   ! [remote rejected] master -&gt; master (n/a (unpacker error))
  error: failed to push some refs to '$URL'
  </code></pre>