how to undelete a deleted remote branch
I accidently did this:
$ git push origin :development To email@example.com:yyyyy/projects/web.git - [deleted] development
How do I undo? What is the second best thing I can do?
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.