【问题标题】:Cloning through SSH makes the server think that GIT’s home directory is the root of the filesystem?通过 SSH 克隆让服务器认为 GIT 的主目录是文件系统的根目录?
【发布时间】:2012-09-07 03:45:26
【问题描述】:

我已经设置了一个简单的服务器,它有一个使用 SSH 连接的 git 帐户。 我尝试使用git clone ssh://git@server:port/repository 克隆位于其主目录(/srv/git)中的存储库。除非我将 ~/ 添加到存储库名称中,否则它将不起作用。 如果我不添加它,那么只有当存储库位于文件系统的根目录时它才会起作用。

不知何故,git 没有实现自己的用户目录。我怎样才能改变这种“奇怪”的行为,使其按预期工作? (至少对我来说)

【问题讨论】:

    标签: git


    【解决方案1】:

    您必须提供绝对路径或使用~ 指示主目录的路径。引用git-clone(1):

    ssh 和 git 协议还支持 ~username 扩展:

    • ssh://[user@]host.xz[:port]/~[user]/path/to/repo.git/
    • git://host.xz[:port]/~[user]/path/to/repo.git/
    • [user@]host.xz:/~[user]/path/to/repo.git/

    另一种解决方案是使用诸如gitolite 之类的东西。然后您将能够使用存储库 URL,例如 sshuser@host:reponame

    【讨论】:

    猜你喜欢
    • 2012-03-15
    • 2021-04-11
    • 1970-01-01
    • 2016-03-05
    • 1970-01-01
    • 1970-01-01
    • 2012-04-09
    • 1970-01-01
    相关资源
    最近更新 更多