2015-09-04 56 views
0

我越來越想克隆一個Git倉庫,當這個錯誤:致命的:「/ MYORG/myrepo」不似乎是一個Git倉庫

[[email protected] ~]$ git clone git+ssh://[email protected]/myorg/myrepo 
Cloning into 'myrepo'... 
fatal: '/myorg/myrepo' does not appear to be a git repository 
fatal: Could not read from remote repository. 

Please make sure you have the correct access rights 
and the repository exists. 

我知道庫中存在,因爲該命令的工作:

[[email protected] ~]$ git clone [email protected]:myorg/myrepo 
Cloning into 'myrepo'... 
remote: Counting objects: 2986, done. 
remote: Compressing objects: 88% (1972/2238) 
.... 

我認爲問題是,第一個命令正在混帳搜索回購/myorg/myrepo,而不是myorg/myrepo,因爲如果我再補充一點額外的/到第二個命令,它停止工作,並顯示完全相同的錯誤消息日e第一個:

[[email protected] ~]$ git clone [email protected]:/myorg/myrepo 
Cloning into 'myrepo'... 
fatal: '/myorg/myrepo' does not appear to be a git repository 
fatal: Could not read from remote repository. 

Please make sure you have the correct access rights 
and the repository exists. 

如何在此存儲庫中使用SSH語法?

(我想我需要的SSH語法的原因是因爲我想與GIT設置端口轉發)

+1

我敢肯定你需要指定如果您使用SSH,則磁盤上的實際路徑到存儲庫。 – meagar

+0

謝謝,那確實是這個問題。我把完整的路徑,現在它的工作。 – MondKin

回答

0

這也應該相對路徑從git主目錄工作:

git clone git+ssh://[email protected]:myorg/myrepo 

git clone git+ssh://[email protected]/~git/myorg/myrepo 

通過那裏放絕對路徑,你不會破壞任何東西。

欲瞭解更多信息

可以爲git-clone(1)討論手冊頁:

GIT URLS

一般來說,網址包含有關的傳輸協議,遠程服務器的地址信息,並存儲庫的路徑。根據傳輸協議,這些信息可能不存在。 Git支持ssh,git,http和https協議(另外,ftp和ftps可以用於讀取,rsync可以用於讀取和推送,但是這些效率不高並且不推薦使用;請不要使用它們) 。

本地傳輸(即git:// URL)不進行身份驗證,應在不安全的網絡上謹慎使用。

以下語法可以與它們一起使用:

  • ssh://[[email protected]]host.xz[:port]/path/to/repo.git/ < -
  • git://host.xz[:port]/path/to/repo.git/
  • http[s]://host.xz[:port]/path/to/repo.git/
  • ftp[s]://host.xz[:port]/path/to/repo.git/
  • rsync://host.xz/path/to/repo.git/

一種替代SCP的語法也可與SSH協議使用:

  • [[email protected]]host.xz:path/to/repo.git/ < - 如果有第一個冒號之前沒有斜線

此語法僅識別。這有助於區分包含冒號的本地路徑。例如,本地路徑foo:bar可以被指定爲絕對路徑或./foo:bar以避免被誤解爲ssh url。

的SSH和git協議還支持〜用戶名擴展:

+0

你不是在那裏混合SSH和GIT語法嗎?如果涉及到SSH,那麼在':'後面會顯示端口號,而不是路徑(即GIT語法)。 – MondKin

+0

ssh本身不接受語法'hostname:port',但是'git clone'。正確的可能性在'git-clone'的手冊頁中。查看修改後的答案 – Jakuje

相關問題