Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to undelete a deleted remote branch

Tags:

git

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?

like image 430
kakarukeys Avatar asked Dec 01 '10 11:12

kakarukeys


People also ask

How do I get back a deleted branch?

A deleted Git branch can be restored at any time, regardless of when it was deleted. Open your repo on the web and select the Branches view. Search for the exact branch name using the Search all branches box in the upper right. Click the link to Search for exact match in deleted branches.

Can we recover deleted branch from GitHub?

Restoring a deleted branchUnder your repository name, click Pull requests. Click Closed to see a list of closed pull requests. In the list of pull requests, click the pull request that's associated with the branch that you want to restore. Near the bottom of the pull request, click Restore branch.

How do I undo a remote branch?

Steps to delete remote Git branchesIssue the git push origin –delete branch-name command, or use the vendor's online UI to perform a branch deletion. After the remote branch is deleted, then delete the remote tracking branch with the git fetch origin –prune command.


1 Answers

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.

like image 140
VonC Avatar answered Oct 11 '22 23:10

VonC