1

I had cloned only one branch of a repo using

git clone -b mybranch --single-branch git://sub.domain.com/repo.git

as explained in Clone only one branch

Now I want to get the entire repo, including all the branches into that very location.

How do I do this?

Community
  • 1
  • 1
Devdatta Tengshe
  • 4,015
  • 10
  • 46
  • 59
  • So I'm assuming you want to mirror the entire repo? https://help.github.com/articles/duplicating-a-repository/#mirroring-a-repository (not posting as an answer yet because I want to be sure) – matrixanomaly May 06 '15 at 14:11

3 Answers3

3

When you use the --single-branch option, you end up with a configuration for the named remote in .git/config that looks something like this:

[remote "origin"]
    url = https://github.com/project/repo.git
    fetch = +refs/heads/some_branch:refs/remotes/origin/some_branch

You can edit the configuration to reset the fetch configuration to the default:

git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'

And then:

git remote update

And now you have the entire repository.

larsks
  • 277,717
  • 41
  • 399
  • 399
2

Easiest way is to just delete your current folder in that location and do normal git clone without all the flags:

git clone git://sub.domain.com/repo.git
Sid
  • 2,683
  • 18
  • 22
0

You can do a normal git clone, or you could do a complete duplicate/mirror that is exactly like the repo you're cloning with

git clone --bare https://github.com/project/example.git

This makes an exact duplicate that copies all the same refs /notes/ but no remote tracking. If you want that as well, then you do:

git clone --mirror https://github.com/project/example.git

The main differences is that --mirror sets up remote tracking, and whatever changes the repo you're mirroring from will be reflected in that mirror copy, it will overwrite it's own refs if needed, this is great for making multiple exact copies of the repo.

More info on duplicating/mirroring a repository here and well as how to properly mirror a git repository

Community
  • 1
  • 1
matrixanomaly
  • 6,627
  • 2
  • 35
  • 58