Search code examples
gitcvsgit-cvs

How to mirror one one git remote to another with push


The problem is a simple one. I've used git cvsimport to import a cvs repo into a remote branch in a local git repository. I then wish to sync this repository: branches, tags, and all, to a git repository in the cloud (github / gitorious). To do this I don't have the access to rsync or copy the repository directly, I have to use git push.

How do I go about mirroring my local repository so others have access to the full _cvsimport_d history?

Concretely:
I import and track a repository using cvsimport:

git cvsimport -i -v -C cdt-make-core -d :pserver:[email protected]:/cvsroot/tools -r cvs org.eclipse.cdt/all/org.eclipse.cdt.make.core

The above imports org.eclipse.cdt.make.core into the remote cvs in the git repo cdt-make-core.

I can then push the HEAD of the main CVS branch to github:

git push github cvs/master:refs/heads/cvs/HEAD

(I specify the path on the remote explicitly so if it doesn't exist it's created.)

Is there any way to sync all the branches: cvs/* => cvs/* on the remote?
Is there any way to sync all the tags?


Solution

  • My findings are that if you use the 2nd reasonable solution below, you need to do the --mirror first, because it wipes out those cvs/ branches you're trying to push. So the complete formula is:

    git push --mirror -v github
    git push --force github cvs/master:refs/heads/cvs/HEAD
    for x in `git branch -r | grep '^..cvs/[a-zA-Z0-9_-]*$' | sed -e 's/^..//'` ; do  
      git push -v github $x:refs/heads/$x
      git config branch.$x.remote github
      git config branch.$x.merge refs/heads/$x
    done