title: Git Extensions Push with default settings (*:refs/heads/*) messes up all branches
body: <h2>The issue</h2>
  
  <p>This sounds like a GitExtensions bug, to which <a href="https://github.com/gitextensions/gitextensions/issues/search?q=push" rel="nofollow noreferrer">I couldn't find specific info</a>. I believe the issue arises when you have a bare repository with more than 1 branch. If you then push, you'll get a warning that if you choose to ignore you'll find the mess up branches. Or depending on how you push it, not even the warning comes up and it's doom everywhere!</p>
  
  <p>Let's say we have 2 local branches called <code>master</code> and <code>another</code>. And the default <code>origin</code> set for pushing. After a regular push we'd also find <code>origin/master</code> and <code>origin/another</code>, that's all.</p>
  
  <p>But after the doomed push, we'll find duplicated <code>origin/master</code> and <code>origin/another</code> plus <code>origin/refs/heads/master</code> and that's also duplicated. For every extra branch. And it's <a href="https://stackoverflow.com/questions/10537095/push-all-local-git-branches-best-practice">not like we're pushing all branches</a> or something, nor are we using <a href="https://github.com/gitextensions/gitextensions/pull/320" rel="nofollow noreferrer">Multiple Branches feature</a>.</p>
  
  <p>In fact, after this happening, we can't even simply <code>push</code> without an error! (yes, using windows of course)</p>
  
  <blockquote>
  <pre><code>Pushing to \\\server\git\repo
  error: dst refspec refs/heads/another matches more than one.
  error: failed to push some refs to '\\\server\git\repo'
  </code></pre>
  </blockquote>
  
  <p>The problem becomes way evident when listing branches with <code>git branch -r</code>.</p>
  
  <h2>To fix it</h2>
  
  <p>We need to do something like this:</p>
  
  <ol>
  <li>Manually remove the <strong><code>refs/heads</code></strong> <em>folder</em> in <code>origin</code>. Some times it works just <a href="https://stackoverflow.com/a/2003515/274502">using</a> <code>git push origin :&lt;branchName&gt;</code>, others we need to go more robust and directly into the folder. This is the hard step and <strong>main problem</strong> happens when those don't work...</li>
  <li><a href="https://stackoverflow.com/a/8255687/274502"><code>git fetch -p</code></a>, for bringing origin changes to local.</li>
  <li>Eventually going through all clients and using <code>git remote update</code>. If needed, removing the same branches, one by one or by any means, like robustly and directly into the folder again. There's yet another problem in this steps, sometimes, which I can't diagnose yet.</li>
  </ol>
  
  <h2>The frequency</h2>
  
  <p>To us, this is a stated fact. Even though I haven't done many experiments to see what exactly causes it, it does happen in any of 5 machines using this repo, all configured the same way except for the <code>bare</code>.</p>
  
  <p>And every single time it happens I have to run and find out on how to fix it. This time I decided to document it, since I could never find anything on the web specific enough.</p>
  
  <h2>Why</h2>
  
  <p>The question here is: <strong>why this happens, and how to prevent it?</strong> Is it even <a href="https://github.com/gitextensions/gitextensions/issues/1209" rel="nofollow noreferrer">GitExtensions fault only</a>? That sure happens, in our side, only with this specific scenario, in GitExtensions.</p>