首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >ssh://和git@版本的git连接字符串之间的差异

ssh://和git@版本的git连接字符串之间的差异
EN

Stack Overflow用户
提问于 2022-11-27 14:44:32
回答 1查看 57关注 0票数 1

我正在尝试使用git服务器码头映像来设置本地git服务器。

我的停靠-撰写配置如下:

代码语言:javascript
运行
复制
  git-server:
    image: jkarlos/git-server-docker
    restart: always
    ports:
      - "22:22"
    volumes:
      - ./docker/git-server/keys:/git-server/keys
      - ./docker/git-server/repos:/git-server/repos

使用此设置,以下两个版本中的第一个版本可以工作,而第二个版本则不能工作。

代码语言:javascript
运行
复制
git clone ssh://git@localhost/git-server/repos/my_repo.git
git clone git@localhost:git-server/repos/my_repo.git

第二个版本提供了以下错误消息:

代码语言:javascript
运行
复制
Cloning into 'my_repo'...
fatal: 'git-server/repos/my_repo.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.

我原以为这两个版本是一样的,但这显然是错误的。有什么关系?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2022-11-27 19:28:24

第一种有效,而第二种则无效。 git克隆ssh://git@localhost/git-server/repos/my_repo.git

是的,它访问了绝对路径/git-server/repos/my_repo.git

git克隆git@localhost:git-server/repos/my_repo.git

它尝试并访问相对路径git-server/repos/my_repo.git

使用绝对路径应该更好:

git克隆git@localhost:/git-server/repos/my_repo.git

代码语言:javascript
运行
复制
                        ^^^^

或者,如果存储库不在/git-server,而是,/another/path/to/git-server/...

git克隆git@localhost:/another/path/to/git-server/repos/my_repo.git ^#完整的完整路径

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74590958

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档