Reputation: 23481
I accidently did this:
$ git push origin :development
To [email protected]:yyyyy/projects/web.git
- [deleted] development
How do I undo? What is the second best thing I can do?
Upvotes: 10
Views: 7483
Reputation: 1324318
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.
Upvotes: 14
Reputation: 1
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
and..
% 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.
Upvotes: -1