how to undelete a deleted remote branch

I accidently did this:

$ git push origin :development
 - [deleted]         development

How do I undo? What is the second best thing I can do?

  • Replace working copy of git repo with actual contents of repo in .git?
  • How to handle pull requests with Git Extensions?
  • Eventmachine start_tcp_server no acceptor - port is in use or requires root privileges (RuntimeError)
  • Git - generate patch for all commits in a branch
  • Run git commands from a C# function
  • Can't execute git command in nodejs
  • “${1-}” vs “$1”
  • Using git, how do you reset the working tree to the state of the index?
  • Delete all git branches which don't add diff over master
  • Git - How to remove work from origin, but merge back in later from another branch?
  • How can I list all the deleted files in a git repository?
  • git repository with folders in different locations
  • 2 Solutions collect form web for “how to undelete a deleted remote branch”

    If your branch was fairly up-to-date with the remote one, a simple:

    git push origin development:development

    should be enough, as illustrated by this thread.
    If not, a local action needs to be done on the remote server side (through reflog or fsck) to retrieve the branch HEAD SHA1 id and checkout it again.

    I have been looking for the method to recover the deleted remote branch for long time.
    I have just found that you can use:

    % git clone –mirror your_remote_repo_url


    % git fetch

    As long as you have run “git fetch” before you deleting the branch,the branch you deleted will be fetched. The behaviour match the git server bakup default rules.

    … in the mirror repo to backup your remote repo. The backup repo will keep all branches including the ones you deleted.

    Git Baby is a git and github fan, let's start git clone.