Reputation: 87
We are learning Git and would like to push only to our main Git server (git.example.com). Which must deploy (based on the repo) to other servers like our development webserver (dev.example.com) and Redmine (redmine.example.com) project management server.
We understand that this can be done by a small configuration in: .git/config
on the workstations like:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = https://git.example.com/testing.git
# Development server only needs to serve the files.
url = https://dev.example.com/testing.git
# Redmine must be a bare one.
url = https://redmine.example.com/testing.git
Our opinion about above solution. First of all that would consume additional bandwidth/upload. Second we don't like that this must be configured on the client side: .git/config
. Is there anyway to configure this at least on git.example.com?
For anybody who has the same question this site did help us a lot: Website maintenance with git, the pro way. Small snippet which you can find on the bottom of that page:
Depending on your needs, you might want to adjust this procedure a bit. Let's say you only want to push changes to the staging server from the bare repository on git.example.com, not from your home computer directly. You can do this by altering the remote.staging.push configuration option to read
refs/remotes/origin/master:refs/heads/master
instead ofrefs/heads/master:refs/heads/master
. This might be useful if you have multiple developers who need to be able to push to the staging server.
We don't completely understand this possible solution. But sounds that it could be a solution for our problem. We are also reading through the Git documentation and will keep you guys posted.
Any help is really appreciated. Thanks in advance.
Upvotes: 3
Views: 310
Reputation: 87
We are still trying to improve our goal. Looks like this page will help us out: http://sitaramc.github.com/gitolite/mirroring.html
Upvotes: 1
Reputation: 33193
You can do this using server side hook scripts. In this case you would want to add to the post-receive hook which is run once the update has been accepted and applied to the servers repository and everything is completed. I used this hook for mirroring a git-tfs repository into a proper git repository with more history by re-applying all patches to the other repo. For your purposes, just calling git push --mirror
for each target would probably be enough. Or you could just run a cron job on the server to do the same thing at regular intervals.
The sample post-receive-email hook script shows how fancy you can get with storing target repositories as config variables and checking that your repositories are in sensible states before you go ahead. Any output from the hook scripts can be shown to the pushing user which helps if things fail for any reason.
Simplest will just be to add some git push --mirror mirror1; git push --mirror redmine
lines to the servers hooks/post-receive script I think.
Upvotes: 2