The Gluster Blog

Gluster blog stories provide high-level spotlights on our users all over the world

Mirroring into Gitorious

Gluster
2013-08-26


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.

Test your ssh, for example:

i.e. ssh git@forge.gluster.org

2) 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.git

And 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. 

Essentially, we can think of mirroring of a git repo as mirroring all the commits + all the branches + all the tags.  And because REFS have all the pointers into the commit graph which define all branches/tags, synchronizing the refs is equivalent to mirroring.  Every commit is pointed to by either a branch or a tag : And so by force.  So in other words, when you say “push –mirror” , your really saying “push all the commits, and all the metadata that structures those commits into tags/branches, into my mirror”. 

BLOG

  • 27 Apr 2020
    Update from the team

    It has been a while since we provided an update to the Gluster community. Across the world various nations, states and localities have put together sets of guidelines around shelter-in-place and quarantine. We request our community members to stay safe, to care for their loved ones, to continue to be...

    Read more
  • 03 Feb 2020
    Building a longer term focus for Gl...

    The initial rounds of conversation around the planning of content for release 8 has helped the project identify one key thing – the need to stagger out features and enhancements over multiple releases. Thus, while release 8 is unlikely to be feature heavy as previous releases, it will be the...

    Read more
  • 28 Nov 2019
    Planning ahead for Gluster releases

    In order to plan the content for upcoming releases, it is good to take a moment of pause, step back and attempt to look at the consumption of GlusterFS within large enterprises. With the enterprise architecture taking large strides towards cloud and more specifically, the hybrid cloud, continued efforts towards...

    Read more