Replication service between Git server and users
I am working on a project to apply Git as the new SCM solution. I understand some principles of Git but I have little experience with this technology.
In order to reduce network traffic it seems plausible to have a single copy of a remote repository in the Lan, instead of always going out of the network each time a developer needs to access something new.
Therefore I wonder if there is any mediation service for Git that can act as “facade” server or replication service, between developers and the Git central instance.
- Does Git have that kind of feature? Is there an add-on that does that?
- If such a feature exists, what are the common pitfalls of using it?
- What are your thoughts on adding that layer of complexity? Is it a good idea?
- If Git does not support it out of the box, what other alternatives are left to achieve that?
The following graphic helps illustrate my point. The “Hypothetical Git Replication” is the name for the replication service which I dont know if exists.
If more information is needed please ask so I can update my question properly.
3 Solutions collect form web for “Replication service between Git server and users”
Yes, it does, or rather there is a system which does just that: Gerrit, and Gerrit replication plugin
If your LAN includes a Gerrit-managed repo, that repo can then replicate to one or several distant repo.
And the reason I know about that particular plugin is because of Episode 30 of GitMinutes, which details the [in]famous force push of 186 Jenkins repositories to GitHub (see “Use the force, Lucas”).
At the time (November 2013), the default for that plugin was a forced push (
git push --f). And that is really not secure 😉
I’m sure you could hack something together to do this, but I don’t think it will give you the benefits you’re looking for:
If you allow team members to push to the internal replication box without forcing the replication box to update from the remote instance you run the risk of the replication box and the remote box getting out of sync.
If the replication box and the remote box get out of sync you’ll be faced with the task of manually resolving merge conflicts between those two boxes. This is unpleasant and can result in messy history.
If you force the replication box to update from the remote box every time a team member tries to
fetchyou’ll be generating nearly as much network traffic as you would without the replication box.
The only way this works cleanly is if the remote instance can only be updated from the internal replication instance. But in that case the internal replication instance is the real central repository and the external one is simply a read-only mirror.
If you only want to use the external instance as a read-only mirror or an offsite backup there are other approaches that are likely better.
Git is generally pretty efficient with its network traffic. Faced with the choice of a little more traffic or a lot more complexity I’ll take a little more traffic anytime.
I think you can use a server on your LAN as a git repository.
First you have to init your repository with the command:
git init --bare
The –bare indicates to the git-daemon that it is authorized to clone this local repository. Or if you already have a project on another rep:
git clone --bare my_project my_project.git
Now anyone with read-access to your server (through ssh or windows file sharing system) will be able to clone and pull from your repository. If they have write access they will be able to push.
In linux the command will look like this:
git clone firstname.lastname@example.org:/path_to_the_project/my_project.git
Now if you want to have an extra repository in the cloud where you push occasionally, you can still do it. You connect yourself to your local server and do something like:
git push http://github.com/my_organisation/my_project
This way you have a local repository where people can pull or push according to their permissions, and you have an external one, which you will have to keep up-to-date manually.
For more info look at the official doc.
I hope it answers your question, you look like a bit fuzzy about it.