Reputation: 747
A bunch of SO questions/answers on pruning the local repo from origin, but I couldn't find an answer for this:
I have a repo test
with branches master
, branch1
, branch2
. I ran git branch -d branch1 branch2
, and now they no longer show. Let's say I want to get these back in my local repo. How do I do this? (Note: This is for learning, so I don't want to use reflog
to restore; I'm trying to understand why I can't get the branches back using the commands I've learned to pull from the server.)
I tried doing git fetch --all
, as well as reset --hard origin/master
, and a couple other things, but while git shows the branches existing on remote (git branch --all
returns /remote/origin/test1
as well as for /origin/test2
), I can't get them back on my local copy.
What do I do?
Upvotes: 1
Views: 36
Reputation: 30317
By fetching you are updating the remote branches (references) on your local. You could create local branches from them:
git branch branch1 origin/branch1
And in case you really lost them locally and have no remote references, you can always check the reflog to get the IDs and create branches from them
git branch branch1 some-old-revision-id
Upvotes: 1