Bogac
Bogac

Reputation: 3707

How to re-create deleted remote branch?

I deleted my remote branch with git push origin :branchName but not locally. It was a mistake.

I want to revive my remote branch if not deleted by garbage collector.

Is that possible?

Because I still have my local intact, I can create new branch on remote of course. But if my accidentally deleted remote branch already there, I'd prefere to make it back with git commands.

Thanks

Upvotes: 3

Views: 1269

Answers (3)

Anshul Goyal
Anshul Goyal

Reputation: 76887

Since you have this on github, you can create the branch back using

git push origin branchName

But that could mean that you miss out on some changes if there are multiple devs working on it and your local branch is not up to date.

In that case, I would suggest contact github tech support to restore the original branch for you, there is no way for you to recover the branch on your own from github's servers. Create a backup branch to save yourself from further troubles anyway:

git push origin branchName:branchName_local_bkp

this will create a new branch called branchName_local_bkp on github.

Upvotes: 2

Oleksandr Horobets
Oleksandr Horobets

Reputation: 1375

If you have absolutely identical local branch the easiest way to go is to re-push local branch again.

If you're using GitHub and have pull request for that branch you can recreate it from GitHub UI.

Upvotes: 0

Dacav
Dacav

Reputation: 14078

Since your local is intact, you can simply push it again.

Upvotes: 0

Related Questions