7

For remote branches that have been removed via git prune --all origin, how do you restore them?

Assumption

There are over 100 branches and shared by a team of 20 people and everyone is working on different sets of branches.

Community
  • 1
  • 1
Boon
  • 40,656
  • 60
  • 209
  • 315
  • That command doesn't seem to be valid. `git prune` doesn't have a `--all` option and it doesn't take a remote as an argument (although that could be a ref name. If it was meant to be `git fetch --prune --all origin`, that would seem a bit closer; but `--all` doesn't work if a remote is specified. – qqx Dec 03 '12 at 02:31
  • I might have forgotten the exact syntax, but bottom line is a bunch of remote branches have been annihilated and what's the best way to recover them, short of pushing each branch back to it again? – Boon Dec 03 '12 at 02:37
  • From which end are the branches missing, the local repository or the remote one? – qqx Dec 03 '12 at 02:43
  • Local and remote for the person who committed this. – Boon Dec 03 '12 at 17:00

1 Answers1

2

Pushing all branches back again seems the easiest solution (as in "Set up git to pull and push all branches")
(unless you find those branches still referenced in the reflog of the server)

Then you can make sure your local repo is tracking them again, with that one-liner in "Track all remote git branches as local branches".

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250