Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change a git repository cloned with --bare to match one cloned with --mirror?

This issue is not the same as git - how to mirror file from other repo or How do I update my bare repo?

Since a repository cloned with --mirror is a bare repository, can I make a repository cloned with --bare be like one cloned with --mirror? Can it be done by simply modifying the config file?

If not, is there other method which can convert a bare repository to a mirror repository?

Another question, Why can I not use git push --all in a mirror repo, while this command can be ran in a bare repo?

like image 581
thinke365 Avatar asked Sep 10 '12 11:09

thinke365


2 Answers

To change a repository cloned with git clone --bare into one that matches what it would be with a git clone --mirror, do the following:

$ git config remote.origin.fetch "+refs/*:refs/*" 
$ git config remote.origin.mirror true

Then do a git fetch and everything should be up-to-date.

like image 128
onionjake Avatar answered Oct 20 '22 01:10

onionjake


If you have clone your repo with git clone --mirror, then a git push --all, following the default matching push policy, will push all local branches to the remote repo.

But if your remote repo has been added to your local repo as a remote reference (ie your local repo has been cloned from another remote repo), then a git push --all secondRemoteRepo won't find many matching branch to push to, unless you fetch those branches first.
So this should work:

git fetch secondRemoteRepo
git push --all secondRemoteRepo
like image 31
VonC Avatar answered Oct 20 '22 01:10

VonC