我有一台运行 Windows 10 的计算机,我想在其上托管 git 存储库。OpenSSH 正在运行,我可以通过 Powershell 通过 SSH 连接到机器,因此它是可连接的。
我在该机器上名为 Test 的文件夹中创建了一个新的 git via
git init --shared --bare
Run Code Online (Sandbox Code Playgroud)
我现在尝试使用 Sublime Merge 和源 URL 进行克隆,如下所示:
ssh://USER@IP:/Test
Run Code Online (Sandbox Code Playgroud)
但是,当我输入密码后,出现两个错误:
fatal: "/Test" does not appear to be a git repository
fatal: Could not read from remote repository
Run Code Online (Sandbox Code Playgroud)
我尝试过用谷歌搜索这两个问题,但没有得到任何有帮助的信息。有人能帮忙吗?
编辑:我可以在远程计算机上本地克隆、提交和推送,所以它绝对是一个 git 存储库。
编辑#2:已修复。遵循本指南,了解如何通过强制存储库使用 powershell(最底部)来直接指向 git 文件夹https://github.com/PowerShell/Win32-OpenSSH/wiki/Setting-up-a-Git-server-on -Windows-使用-Git-for-Windows-and-Win32_OpenSSH
**请注意,由于已知问题,git clone user@domain@servermachine:C:/test/myrepo.git 不起作用。解决这个问题,将 powershell 设置为注册表中的默认 Shell。或者当 cmd 是默认 shell 时执行以下步骤:
Run Code Online (Sandbox Code Playgroud)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 获取原点
在这里您可以找到如何拥有存储库的完整教程。
https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server
该存储库适用于 Linux,但我认为步骤应该类似。当您使用以下命令创建裸存储库时:
$ cd /srv/git
$ mkdir project.git
$ cd project.git
$ git init --bare
Initialized empty Git repository in /srv/git/project.git/
Run Code Online (Sandbox Code Playgroud)
通常将文件夹命名为.git. 但之后您应该能够使用以下命令进行克隆。
git clone git@gitserver:/srv/git/project.git
Run Code Online (Sandbox Code Playgroud)
所以您已经添加了 Git 文件夹的路径。我认为这是你的问题。您仅尝试根目录中的路径“/Test”。这可能是错误的,Git 会告诉您该文件夹不是 Git 存储库。