Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mirror one one git remote to another with push

Tags:

git

git-cvs

cvs

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?

like image 665
James Blackburn Avatar asked Sep 08 '09 09:09

James Blackburn


People also ask

How do I push a git repo to another remote?

To push the commit from the local repo to your remote repositories, run git push -u remote-name branch-name where remote-name is the nickname the local repo uses for the remote repositories and branch-name is the name of the branch to push to the repository. You only have to use the -u option the first time you push.

How do I push one remote branch to another remote branch?

Push a new Git branch to a remote repo Clone the remote Git repo locally. Create a new branch with the branch, switch or checkout commands. Perform a git push with the –set-upstream option to set the remote repo for the new branch. Continue to perform Git commits locally on the new branch.

How do I mirror an entire existing git repository into a new one?

You first have to get the original Git repository on your machine. Then, go into the repository. Finally, use the --mirror flag to copy everything in your local Git repository into the new repo.


1 Answers

I think you're looking for the --mirror option to push:

git push --mirror github

This will push all refs (branches and tags) including non-fast-forward updates. I use this for creating backups of my local repository.

The man page describes it like this:

Instead of naming each ref to push, specifies that all refs under $GIT_DIR/refs/ (which includes but is not limited to refs/heads/, refs/remotes/, and refs/tags/) be mirrored to the remote repository. Newly created local refs will be pushed to the remote end, locally updated refs will be force updated on the remote end, and deleted refs will be removed from the remote end. This is the default if the configuration option remote.<remote>.mirror is set.

[OT: I use CDT in my everyday work and I love it!]

like image 79
Pat Notz Avatar answered Oct 05 '22 23:10

Pat Notz