2013-04-16 58 views
2

我是git的新手。我在有SSH访问权限的服务器上创建了一个裸存储库。如果我尝试将其克隆到我的工作站,我得到两个不同的结果:为什么git clone user @ server在git clone ssh:// user @ server不工作时工作?

% git clone ssh://[email protected]:git/foo.git 

Cloning into 'foo'... 
ssh: example.com:git: no address associated with name 
fatal: Could not read from remote repository. 

但如果我删除ssh://,它工作正常:

% git clone [email protected]:git/foo.git 

据临Git的书,这些应该是相同。

什么给?

回答

7
  • 第一个命令git clone ssh://,遵循标准SSH URI syntax,因此你需要给出绝对路径。

    试试这个,例如(假定主目录为用户me位于/home/me):

    git clone ssh://[email protected]/home/me/git/foo.git 
    

    而且我猜这也应该工作:

    git clone ssh://[email protected]/~/git/foo.git 
    
  • 第二语法:git clone [email protected]:git/foo.git允许使用用户主目录中的相对路径。

+0

非常感谢! – Will