tags:

views:

249

answers:

1

I am having great success with git push --mirror to make backup copies to a bare repo. But after search on SO and elsewhere, I cannot find a way to clone the thing locally with all branches. I do not want to use git clone since I don't want my local repo to know about the bare repo. If I use git pull it only brings down the HEAD branch.

Guessing:

git pull /data/Dropbox/backup/that_stuff.git *

gets me nowhere, of course.

How do I get the entire repo with all branches back again? I realize I could probably just copy the bare repo to my .git directory, but that seems like a bad idea.

+1  A: 

Try git fetch instead of git pull

Since git pull is there to fetch a branch and merge it to a local branch, it wouldn't make alot of sense trying to merge all remote branches to a local branches.

$ git fetch a-repo_url

The above command copies all branches from the remote refs/heads/ namespace and stores them to the local refs/remotes/remoteRpo/ namespace, unless the branch.<name>.fetch option is used to specify a non-default refspec..
Try:

$ git fetch a-repo-url +refs/heads/*:refs/heads/*

could force fetching all heads for all branches.
See this SO question.


The OP yar reports:

git pull /data/Dropbox/backup/mjdj.git/ +refs/heads/*:refs/heads/*

works.

VonC
Tried that. GIT responds `* branch HEAD -> FETCH_HEAD`... so it just gets that one.
Yar
Tried that last one with the asterisks... fatal: Refusing to fetch into current branch refs/heads/master of non-bare repository
Yar
@yar: Maybe it needs a remote reference (http://www.kernel.org/pub/software/scm/git/docs/git-remote.html), but that would mean "making your local repo to know about the bare repo", which is not what you want.
VonC
Sorry this did it! Thanks `git pull /data/Dropbox/backup/mjdj.git/ +refs/heads/*:refs/heads/*` ... if you can update your answer I'll mark it
Yar
@yar ... and updated.
VonC
Awesome, we could do a TV show. Thanks!
Yar
But with a five to seven minutes delay each line of the conversation...
VonC
totally. that's what the songs are for.
Yar