通过SSH进行克隆会让服务器认为GIT的主目录是文件系统的根目录? [英] Cloning through SSH makes the server think that GIT’s home directory is the root of the filesystem?

查看:102
本文介绍了通过SSH进行克隆会让服务器认为GIT的主目录是文件系统的根目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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



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

解决方案

你必须使用〜提供绝对路径或路径〜 表示主目录。从 git-clone(1 )


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



$ ul
  • 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


    I have set up a simple server with a single git account to which I connect using SSH. I try to clone a repository located in its home directory (/srv/git) with git clone ssh://git@server:port/repository. It won’t work unless I prepend ~/ to the repository name. If I don’t prepend it, it will work only if the repository is located at the root of the filesystem.

    Somehow, git is not realizing its own user directory. How can I change this "odd" behaviour so it works as expected? (at least for me)

    解决方案

    You have to provide an absolute path or a path using the ~ to indicate the home directory. Quoting from git-clone(1):

    The ssh and git protocols additionally support ~username expansion:

    • 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/

    An alternate solution would be using something such as gitolite. Then you will be able to use repository URLs such as sshuser@host:reponame

    这篇关于通过SSH进行克隆会让服务器认为GIT的主目录是文件系统的根目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆