4

well, I've made a very terrible mistake which first I just want to delete the remote connection to another repositories.

I've made the command like this: git push dev :test

which after I check on the github, I'm just realize that the branch test already deleted.

Question: how can I get the branch back? Is it possible to undo the command which I've already made?

spring
  • 95
  • 1
  • 4

3 Answers3

6

Do you still have the local copy with you? Run git branch to check, you probably still have your local branch there since you don't mention removing the local branch.

If this is this case, just push to the remote repository again, with git push dev test without the colon.

kristinalim
  • 3,459
  • 18
  • 27
0

I have the branch on my repositories.

If you haven’t removed it in your local repository yet, you can just push it again to recreate it.

git push dev localbranch:test

Or if you don’t have the branch itself, but still remember which commit was on top, you can also just push that commit directly:

git push dev some-commit-hash:test
poke
  • 369,085
  • 72
  • 557
  • 602
-1

that's not possible to recover after a remote branch is deleted.

since git is DVCS, you'd pray that others didn't get their local copy updated, let them help forth push your test branch into remote. that's the only way to get your branch back, I guess.

since you're in github, maybe there're some forks available? that's also an alternative.

yuwang
  • 846
  • 11
  • 24