Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I recover git pruned remote branches?

Tags:

git

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.

like image 888
Boon Avatar asked Dec 03 '12 01:12

Boon


People also ask

Does git prune delete remote branches?

The prune option removes any remote tracking branch in your local repository that points to a remote branch that has been deleted on the server. With the local branch deleted, the remote tracking branch deleted, and all instances of the remote git branch deleted as well, the remote Git branch should be gone forever.

What does prune remote branches during fetch?

In summary when enabling the prune on every fetch, this means your local list of branches is always up-to-date with the remote. Pruning will cleanup and remove your local tracking branches that no longer exist on the server.


1 Answers

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".

like image 103
VonC Avatar answered Nov 10 '22 06:11

VonC