English 中文(简体)
need to use git behind firewall: trying ssh tunneling
原标题:

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!

最佳回答

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
问题回答

The short version of Vlad Zloteanu s answer:

Set up the tunnel:

ssh ServerWithSSHAccessAddress -L 2000:GitServerAddress:22 -N , &

Clone the repo

git clone ssh://user@localhost:2000/my_repo.git

Here are the steps that worked for me. My system is behind company firewall and it is domain joined:

  • First npm needs to be installed
  • Fiddler needs to be in running mode as well. Fiddler needs to be running with ‘Automatically Authenticate’ option under ‘Rules’ enabled
  • Install Git via command:

npm install git

  • Update protocol from git to https:

git config --global url.https://github.com/.insteadOf git://github.com/





相关问题
git confusion - cloning a repo is returning a past version

Im having some confusion with my git usage. I cloned a repo from one comp to the other, and the new clone is the state of the original that was active some time ago. So its cloning a past version. ...

Appropriate strategy for tagging and hotfixing with git

I was wondering if the strategy I m using for tagging and hotfixing tags (which then I use for deploying rails applications) with git is appropriate. For tagging I just tag a commit of the master ...

Tips on upgrading CVS to git/hg?

We still use CVS, I use git and hg for my personal use though I m still a novice at both, but I realize they re much more modern and better, faster, distributed, etc. It s just everyone is so ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

热门标签