9

(suppose) I have my own git, so you can do

  git clone https://official.example.org/myproject.git

But, at my server official.example.org I want to redirect it to Github. How to do it at UBUNTU 16LTS standard git-server? It is an usual web-server redirect (eg. Apache) or need special preparation?

PS: the technology exist, as announced here.

Peter Krauss
  • 13,174
  • 24
  • 167
  • 304
  • **Answer**: use reverse proxy and HTTP instead HTTPS to use Github certificate... Example that is runing, any repo at http://git.ok.org.br work fine (!). Example: `git clone http://git.ok.org.br/suporte` – Peter Krauss Aug 18 '17 at 23:29

2 Answers2

1

I use the git post-receive hook in my buildfarm to automatically build projects in Jenkins when code is pushed to my git repository. You could do something similar with some of the other git hooks on your server to push code to github.

Similarly, on github you could define a webhook to update your git repository on official.example.org whenever code in the github repository is updated. Something like this answer maybe.

Community
  • 1
  • 1
Gary
  • 6,357
  • 5
  • 30
  • 36
  • Hi @Gary, thanks (!). Can you show a code line example? At [buildfarm-quickstart](https://github.com/gclayburg/buildfarm#buildfarm-quickstart) there are no redirection, the line is `git clone git@github.com:gclayburg/buildfarm.git`, but I need `git clone git@official.example.org:gclayburg/buildfarm.git` redirecting to it. – Peter Krauss Apr 03 '17 at 11:17
  • Unfortunately, I'm not aware of a simple command that will turn your git server into a complete gateway. I'm just saying that it is definitely possible to cobble together several tools to make this work. It sounds like a candidate for a good open source project though. Maybe someone else has already done it? – Gary Apr 03 '17 at 15:40
  • Thanks Gary, a good answer, but only an "expanded version" of my PS, "the technology exist, as announced here" (link to Github showing that it is definitely possible). If nobody post something better, I will give 1 up-vote, but you need 2 votes to get a half bounty. – Peter Krauss Apr 04 '17 at 11:36
0

As far as I know, it's not possible. On Github, the old repository will be redirected to the new one in the same domain and it's the main point here.

Trying to redirect official.example.org to github.com will broke the certificate's chain, making it impossible to handle.

Udlei Nati
  • 502
  • 4
  • 12
  • 1
    It can be done; for HTTP/HTTPS git it should be as easy as an apache redirect (which is a `302 Found` redirect, not a proxy/reverse proxy, and I’m pretty sure is allowed even with https). With ssh clone it should be possible to MITM it because the client believes (correctly) it is connecting to official.example.org, not github. Same for `git` internal protocol. I don’t know *how* to do it for all of these, which is why I’m not answering, but I’m almost certain it is possible. – Daniel H Mar 30 '17 at 19:10