I have a project hosted on git.debian.org (alioth) and I’d like to configure a post-receive hook to update a mirror of the repository on http://gitorious.org
I suppose I’ll have to use git push --mirror gitorious
Now, I’ll need to have Alioth authorized on gitorious for the push to succeed. How do I do that?
I suppose I need to configure a user on gitorious and create a ssh key for it. And then when I do the git push in the post-receive hook, make sure this ssh key is used.
I could use a ~/.ssh/config but the problem is that many users can push on alioth, and everyone would have to log in and configure the ~/.ssh/config. Instead, I’d like to have a command line option or an environment variable to tell ssh which key to use. Can I do that?
Also, do you have other ideas how mirroring can be achieved? And, is it possible to configure it the other way around (gitorious pushing on alioth)?
The answer is to be found in the git reference manual.
So, I need to write a wrapper script, I write this
push-gitorious.shscript:Of course, you have to fill in the private key (the public key is included in the script for reference only. You also need to fill in the gitorious URL.
In the post-receive hook, you have to put:
The run option is important, otherwise it will run ssh directly.
Warning: no checking is done on the remote host identity. You can remove the option from the ssh command line and customize
known_hostsif you want to. In this use case, I don’t think it’s important.