0

I need to push to a git repository from a server that has no access to it (it is blocked at IP level and my server's IP address is not in the allowed segment).

Let's assume I have a second server which has access to the git repository: would it be possible to set it up as a "git proxy" so that the first server can push into the second and this one into the main git repository?

I guess it is, and I have a slight idea about what I should search/do in order to set it up, but I'd like to know if there is a simple straightforward way to accomplish this task.

Thank you in advance.

salvarez
  • 87
  • 1
  • 8

1 Answers1

0

If you're using Git over SSH, a standard SSH tunnel should let you push to your Git server without requiring a second Git repository. Something like this:

  1. Establish an SSH connection from your blocked server to your non-blocked server that includes a tunnel to your target Git server:

    ssh non.blocked.server -L 2222:git-host.com:22
    
  2. In a separate terminal, while the SSH connection is still active, issue Git commands targeting localhost:2222; these will be tunnelled through the SSH connection and be sent to your Git host while appearing to originate from your non-blocked server:

    git ls-remote localhost:2222/some/repo.git
    

If you're using HTTPS instead, look into HTTP proxies to do the same thing.

And finally, you could set up your non-blocked server as a Git remote of your blocked server. Then you could git push from the blocked server to the non-blocked server, and then git push again from the non-blocked server to the Git host. Note that in this case you probably want to create a bare repository on the non-blocked host instead of a regular repository.

Community
  • 1
  • 1
ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257