【问题标题】:Windows, Git and the SSH url/path of a bare repositoryWindows、Git 和裸存储库的 SSH url/路径
【发布时间】:2020-08-04 07:16:12
【问题描述】:

我正在尝试在我们的 Windows 服务器上设置一个 git 存储库。
我安装了适用于 Windows 的 OpenSSH 和适用于 Windows 的 Git。
OpenSSH 服务器在端口 2345 上运行以过滤掉通用机器人。

我在 C:\git\protocolrepo.git 上创建了一个裸共享存储库
我无法通过 URL 访问它:

ssh://User@domain@server.com:2345:C:/git/protocol.git

在我看来,这似乎是一个格式错误的 URL,但我在网络上看到的任何地方都得到了这个,但它就是不起作用。

正如我在这个线程中发现的:https://github.com/PowerShell/Win32-OpenSSH/issues/895,shell 可能是原因,所以我将 powershell 设置为 OpenSSH 的默认 shell。
这也不起作用,我仍然需要使用这个奇怪的 URL。
所以我安装了 Cygwin 并将 Cygwin bash 设置为默认 shell,并使用了更合适的 url:

ssh://User@domain@server.com:2345/cygdrive/c/git/protocol.git 

我在这方面取得了一些成功,但它现在显示以下错误消息:

fatal: '/cygdrive/c/git/protocol.git' 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.

访问权限应该没问题,因为我使用的是同一个用户,但我不能 100% 确定这在 Windows 上是如何工作的。
我不确定 Git/ssh 如何在 Windows 上处理此路径。

在基于 Linux 的服务器上,这与 /git/protocol.git 路径配合得很好。

将新分支推送到裸存储库是我有一段时间没有做过的事情,所以这里也可能做错了,但我不记得这是个问题。

你会推荐什么来调试这个问题?

【问题讨论】:

    标签: windows git ssh cygwin openssh


    【解决方案1】:

    在考虑使用 Git repo SSH URL 之前,我会先检查交互式 SSH 会话是否有效。

    ssh -p 2345 User@domain@server.com
    

    如果是,请尝试在该交互式 shell 中访问 /C/git/protocol.git

    如果可行,那么试试你的 git 命令的 URL

    ssh://User@domain@server.com:2345/C/git/protocol.git
    # or
    ssh://User@domain@server.com:2345/c/git/protocol.git
    

    【讨论】:

    • 先生您好。 VonC,谢谢你的建议。我与 ssh 连接,我可以到达 /cygdrive/c/git/protocol.git 的存储库目录。我已经测试过了。我怀疑 ssh url 可能用 git 处理不同,也许我需要设置一个 git 根目录或类似的东西。无论如何感谢您的帮助!
    • @Eyso 您在问题中提到的 URL 语法不正确:您可以试试我在答案中提到的那个吗?
    • 我尝试了您建议的网址(当然,已调整),但我收到了相同的错误消息。
    • @Eyso 在互动环节,你能做一个ls /c/git/protocol.git吗?还是只能通过/cygdrive/c/git/protocol.git
    • 仅通过 /cygdrive/c/git/protocol.git
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-12
    • 1970-01-01
    • 2019-09-30
    • 2014-08-03
    • 2013-01-14
    • 2013-12-18
    相关资源
    最近更新 更多