title: Git: Recover deleted (remote) branch
body: <p>I need to recover two Git branches that I somehow deleted during a push.</p>
  
  <p>These two branches were created on a different system and then pushed to my "shared" (github) repository.</p>
  
  <p>On my system, I (apparently) retrieved the branches during a fetch:</p>
  
  <pre><code>~/myfolder&gt; git fetch
  remote: Counting objects: 105, done.
  remote: Compressing objects: 100% (58/58), done.
  remote: Total 62 (delta 29), reused 0 (delta 0)
  Unpacking objects: 100% (62/62), done.
  From github.com:mygiturl
   * [new branch]      contact_page -&gt; origin/contact_page
     731d1bb..e8b68cc  homepage   -&gt; origin/homepage
   * [new branch]      new_pictures -&gt; origin/new_pictures
  </code></pre>
  
  <p>Right after that I did a push to send my local changes up to the central repo. For some reason, these branches were deleted from both my local system and the central repo:</p>
  
  <pre><code>~/myfolder&gt; git push
  Counting objects: 71, done.
  Delta compression using up to 2 threads.
  Compressing objects: 100% (43/43), done.
  Writing objects: 100% (49/49), 4.99 KiB, done.
  Total 49 (delta 33), reused 0 (delta 0)
  To git@github.com:mygiturl.git
   - [deleted]         contact_page
   + e8b68cc...731d1bb homepage -&gt; homepage (forced update)
     bb7e9f2..e0d061c  master -&gt; master
   - [deleted]         new_pictures
     e38ac2e..bb7e9f2  origin/HEAD -&gt; origin/HEAD
     731d1bb..e8b68cc  origin/homepage -&gt; origin/homepage
     e38ac2e..bb7e9f2  origin/master -&gt; origin/master
   * [new branch]      origin/contact_page -&gt; origin/contact_page
   * [new branch]      origin/new_pictures -&gt; origin/new_pictures
  </code></pre>
  
  <p>It's not terribly easy to get the branches off of their birthplace machine, so I'd like to try and recover them from my local if possible.</p>
  
  <p>All of the git "undo" information I've googled has to with recovering lost commits. I don't think that applies here, since I don't have commit UIDs for these branches.</p>
  
  <p>I'd like to know how I can get these back. I'd also like to know how they were deleted in the first place and how I can avoid this in the future.</p>
  
  <p>EDIT: by request, here's my repo configuration</p>
  
  <pre><code>user.name=Craig Walker
  user.email=github@softcraft.ca
  alias.unadd=reset HEAD
  core.repositoryformatversion=0
  core.filemode=true
  core.bare=false
  core.logallrefupdates=true
  core.ignorecase=true
  remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
  remote.origin.url=git@github.com:MyGitURL.git
  remote.origin.mirror=true
  branch.master.remote=origin
  branch.master.merge=refs/heads/master
  alias.undo=reset --hard
  alias.test=push -f ci HEAD:master
  alias.st=status
  alias.ci=commit
  alias.br=branch
  alias.co=checkout
  alias.ch=checkout
  alias.df=diff
  alias.lg=log -p
  alias.who=shortlog -s --
  remote.ci.url=ContinuousIntegrationGitURL
  remote.ci.fetch=+refs/heads/*:refs/remotes/ci/*
  branch.photo.remote=origin
  branch.photo.merge=refs/heads/photos
  remote.foo.url=FooGitURL
  remote.foo.fetch=+refs/heads/*:refs/remotes/cynthia/*
  branch.homepage.remote=origin
  branch.homepage.merge=refs/heads/homepage
  </code></pre>