簡體   English   中英

嘗試通過 SSH 克隆時“似乎不是 git 存儲庫”

[英]"Does not appear to be a git repository" when trying to clone via SSH

我有一台運行 Windows 10 的機器,我想在它上面托管一個 git 存儲庫。 OpenSSH 正在運行,我能夠通過 Powershell SSH 進入機器,因此它是可連接的。

我在那台機器上的一個名為 Test 的文件夾中創建了一個新的 git 通過

git init --shared --bare

我現在正在嘗試使用 Sublime Merge 和源 URL 進行克隆,如下所示:

ssh://USER@IP:/Test

但是,輸入密碼后,出現兩個錯誤:

fatal: "/Test" does not appear to be a git repository

fatal: Could not read from remote repository

我試過用谷歌搜索這兩個問題,但沒有得到任何幫助。 有人可以幫忙嗎?

編輯:我可以在遠程機器上本地克隆、提交和推送,所以它絕對是一個 git repo。

編輯 #2:已修復。 遵循本指南,了解如何通過強制存儲庫使用 powershell(非常底部)來直接指向 git 文件夾https://github.com/PowerShell/Win32-OpenSSH/wiki/Setting-up-a-Git-server-on -Windows-using-Git-for-Windows-and-Win32_OpenSSH

**請注意,由於已知問題, git clone user@domain@servermachine:C:/test/myrepo.git 不起作用。 解決它以將 powershell 設置為注冊表中的默認 Shell。 或者當 cmd 是默認 shell 時按照以下步驟:

 cd c:\\mygitrepros # initialize a local repo folder git init mylocalrepo cd mylocalrepo # add the remote repro git remote add origin user@domain@servermachine:C:/test/myrepo.git # work around the known issue by launching powershell to run the git commands git config --local remote.origin.uploadpack "powershell git-upload-pack" git config --local remote.origin.receivepack "powershell git-receive-pack"

git 獲取來源

在這里你可以找到一個完整的教程如何創建一個 repo。

https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server

該 repo 適用於 linux,但我認為步驟應該相似。 當您使用以下命令創建裸存儲庫時:

$ cd /srv/git
$ mkdir project.git
$ cd project.git
$ git init --bare
Initialized empty Git repository in /srv/git/project.git/

通常用.git命名文件夾。 但是在那之后,您應該可以使用以下命令進行克隆。

git clone git@gitserver:/srv/git/project.git

因此,您已將路徑添加到 Git 文件夾。 我認為那是你的問題。 您只嘗試根目錄中的路徑“/Test”。 這可能是錯誤的,Git 會告訴您該文件夾不是 Git 存儲庫。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM