Github is great for collaborating with the world but gitorious is emerging as an alternative which is "truly" open source. The democratic and atomic nature of git lends itself to the idea that any "hub" for commits should by easy to synchronize with any other, equivalent hub ~ by simply using commits as currency.
This assumes you have a working github repo, and that you can ssh/pull from it using your public ssh keys.
Now... here's how to mirror from github into gitorious, so that your gitorious repo is always up to date with your github repo. This is unidirectional, but you can make the mirroring bi-directional by setting up two way mirroring if you want to get really fancy.
1) First make sure you set up your gitorious credentials.
This is essentially the same process as setting up github credentials.
- Go to : https://<gitorious_url>/~<user_name>/keys (i.e. https://forge.gluster.org/~jayunit100/keys)
- Then click on "add ssh key.
- copy the contents of "cat ~/.ssh/id_rsa.pub" into the box.
i.e. ssh git@forge.gluster.org2) Add the gitorious remote repository into your githhub cloned project:
Quick aside: Remember here that gitorious "projects" have no equivalent in github. In github, like git, there are only repositories, not projects. Gitorious adds the notion of a "project" which can have many "repositories" underneath it.
git remote add mirror1 git@<mirror_site>:<project>/<repository>.git
i.e. git remote add mirror1 git@forge.gluster.org:hadoop/glusterfs-hadoop.gitAnd then open a crontab and add the following line (synchronize a couple times a day)
00 09-18 * * * cd /path/to/githubrepo && git checkout master && git pull && git push forge --mirror
At that point, your machine will now push the entire mirroring down to gitorious peridoically.
Now... why are we chekcking out master? WEll, it appears that you cant push if you are in a detached head state, which seems to happen sometimes (to me at least). I'm not sure why - I would think that mirror pushes should be able to occur regardless of your HEAD state, since the HEAD is irrelevant when pushing a full mirror. I've asked this here on stackoverflow and we will see what the real answer is :)
3) Your done !
You should be able to now see all of your most recent commits mirror pushed by your git user on the master branch in your gitorious repo.
Another aside: How mirroring really works.
Mirroring is a special type of push. From the git documentation, adding the mirror option really forces a perfect mirror:
- 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.
No comments:
Post a Comment