Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I push/pull between git repositories when both are behind firewalls/NATs/...?

Tags:

git

dvcs

dns

dhcp

I'm intrigued by git. I've used nearly all of the usual players over the past decades. Currently on SVN and not really happy.

I think I understand the basics, but I don't understand one key concept about the distributed nature: how does a user in his/her house talk to/from my computer (separate houses, ISP, etc.) , when we both have dynamic IP addresses from our ISPs, and use at least one level of firewall/NAT to hide the local network address from the world.

It's not as if there is a useful DNS entry pointing to the other host/PC/laptop. And most (all?) ISPs don't make it obvious how you open ports in general (sure, I can do it in my house, but what about when I'm in a hotel room?)

Any pointer to the answer to this FAQ greatly appreciated.

like image 223
fishtoprecords Avatar asked Oct 22 '25 03:10

fishtoprecords


2 Answers

This isn't a git question per se. If you were hosting, say, a Subversion repository on your laptop, other developers will still have trouble talking to it while you're in a hotel room. You'll need to make your repos available by tunneling through other protocols or pushing them to mutually accessible resources.

The worst but still operable case is when repos can't talk to each other directly, but you can email patches to each other with git send-email.

Next up the ladder, say you have a shell account with an internet provider that also provides ~/public_html. In that case, you'd create in that webspace a bare repository as described in Setting up a git repository which can be pushed into and pulled from over HTTP(S). Your pushes would be authenticated via SSH, and your collaborators would set up remotes to pull from the appropriate HTTP URL.

That's marginally better than email but slow and klunky. Now git has the benefit of a smart HTTP backend where pulls over HTTP are much faster. With either the smart or the dumb backend, you can enable authentication.

If you don't care about authentication, you could also serve your repository with git daemon from a host that everyone can reach.

If you both have shell access to the same host, you could exchange work directly after connecting to that box. You have many options here:

  • full shell access: same account, same (centralized) repo
  • full shell access: different accounts, separate repos, git pull
  • allow collaborators git-only access to your shell account
  • (and so on)

The above might do in a pinch, but all the manual care and feeding will become tiresome. Outsource that headache to GitHub or Gitorious.

like image 149
Greg Bacon Avatar answered Oct 23 '25 18:10

Greg Bacon


You both talk to a central server (eg, GitHub) using normal outgoing HTTPS requests.

like image 39
SLaks Avatar answered Oct 23 '25 19:10

SLaks