views:

596

answers:

1

Hi,

I am trying to use ssh port forwarding to defeat corporate firewall:

ssh git@GIT_SERVER -L9418:GIT_SERVER:9418

and in another terminal I run

git clone git://localhost:repositories/project.git

But I get the following error:

Initialized empty Git repository in /Users/aboxer/tmp/glucosia/.git/

fatal: Unable to look up localhost (port repositories) (nodename nor servname provided, or not known)

Thanks!

+1  A: 

I'm pretty sure your problem (or at least the one causing this particular error) is here:

git clone git://localhost:repositories/project.git

If you look at the list of url notations in man git push you'll see the relevant example:

git://host.xz[:port]/path/to/repo.git/

With the colon, you're using "repositories" as the port name, and git (understandably) has trouble connecting to port repositories on local host! What you're looking for is:

git://localhost/path/to/repositories/project.git

or perhaps

git://localhost/~user/repositories/project.git

Edit:

I probably should've said this from the start, but I can't actually think of a reason you'd need to use SSH tunneling with git. Its default transport protocol is ssh; the git protocol is really only present to allow public repositories to be fetched from without an account. If you can SSH into the machine where the repository is located, you can just fetch via ssh:

git clone ssh://[user@]host.xz/path/to/repo.git
git clone ssh://[user@]host.xz/~/path/to/repo.git
git clone ssh://[user@]host.xz/~user/path/to/repo.git
Jefromi
yeah, the funny thing is that when I am not behind the firewall, the command git clone git://GIT_SERVER:repositories/project.git works fine, but git clone git://GIT_SERVER/repositories/project.git does not
Jacko
@Jacko: I take it that you mean that removing the colon here doesn't help? Also, is there any reason you can't simply use `git clone ssh://GIT_SERVER/path/to/repositories/project.git`? Git's default transport protocol is ssh...
Jefromi
Thanks, Jefromi. Fetching via ssh as described in your edit works fine.
Jacko