-1

I've backed up my repository using git clone. I've used the commands described here to restore it:

How to convert a normal Git repository to a bare one?

My original shared repository had many branches. e.g.

git branch -a
* master
branch1
branch2

However the the shared repository restored from the back up, all the branches are missing

git branch -a 
* master
remotes/origin/branch1
remotes/origin/branch2

Are there any steps I should do to restore the branches in my shared repository that's restored from a clone

Community
  • 1
  • 1
Sunil Khiatani
  • 337
  • 4
  • 12
  • 1
    Check `git branch -r`, you'll find the branches are there. – user229044 Jun 25 '14 at 03:30
  • I forgot to list the remote branches in the rested shared repository. Thanks for that. I understand that the branches are there, but how do I restore them in the restored repository? – Sunil Khiatani Jun 25 '14 at 04:16
  • This is probably a duplicate of some other question involving "missing" (hint: not really missing) branches in fresh Git clones. –  Jun 25 '14 at 04:37
  • Duplicate of [Clone all remote branches with Git?](http://stackoverflow.com/questions/67699/clone-all-remote-branches-with-git) –  Jun 25 '14 at 04:42

1 Answers1

1

This command

git branch -a 
* master
remotes/origin/branch1
remotes/origin/branch2

shows that the branches are still in your repository, they're just remote-tracking branches under .git/refs/remotes/origin/, instead of regular local branches under .git/refs/heads/.

Just create local copies under .git/refs/heads/ like you would with any other kind of branch:

git branch branch1 remotes/origin/branch1
git branch branch2 remotes/origin/branch2

Documentation

Here is the syntax for creating branches (from the [official git-branch(1) Manual Page](https://www.kernel.org/pub/software/scm/git/docs/git-branch.html, truncated for brevity):

git branch <branchname> [<start-point>]

The <start-point> can be, among other things, any kind of branch reference, or a commit sha.