title: How do I synchronise two remote Git repositories?
body: <p>I have two repository urls, and I want to synchronise them such that they both contain the same thing. In Mercurial, what I'm trying to do would be:</p>
  
  <pre><code>hg pull {repo1}
  hg pull {repo2}
  hg push -f {repo1}
  hg push -f {repo2}
  </code></pre>
  
  <p>This will result in two heads in both repos (I know it's not common to have two heads, but I'm doing this for synchornisation and it needs to be non-interactive. The heads will be merged manually from one of the repos and then the sync run again).</p>
  
  <p>I'd like to do the same thing in Git. Eg., with no user interaction, get all of the changes into both repos, with multiple branches/heads/whatever to be merged later.
  I'm trying to do this using urls in the commands, rather than adding remotes(?), as there could be a number of repos involved, and having aliases for them all will just make my script more complicated.</p>
  
  <p>I'm currently cloning the repo using <code>git clone --bar {repo1}</code> however I'm struggling to "update" it. I've tried <code>get fetch {repo1}</code> but that doesn't seem to pull my changes down; <code>git log</code> still doesn't show the changeset that has been added in repo1.</p>
  
  <p>I also tried using <code>--mirror</code> in my <code>push</code> and <code>clone</code>, but that seemed to remote changesets from repo2 that didn't exist locally, whereas I need to keep changes from both repos :/</p>
  
  <p>What's the best way to do this?</p>
  
  <p><strong>Edit:</strong> To make it a little clearer what I'm trying to do...</p>
  
  <p>I have two repositories (eg. BitBucket and GitHub) and want people to be able to push to either (ultimately, one will be Git, one will be Mercurial, but let's assume they're both Git for now to simplify things). I need to be able to run a script that will "sync" the two repos in a way that they both contain both sets of changes, and may require merging manually later.</p>
  
  <p>Eventually, this means I can just interact with one of the repos (eg. the Mercurial one), and my script will periodically pull in Git changes which I can merge in, and then they'll be pushed back.</p>
  
  <p>In Mercurial this is <em>trivial</em>! I just pull from both repos, and push with <code>-f/--force</code> to allow pushing multiple heads. Then anybody can clone one of the repos, merge the heads, and push back. I want to know how to do the closest similar thing in Git. It must be 100% non-interactive, and must keep both repos in a state that the process can be repeated infinitely (that means no rewriting history/changing changesets etc).</p>