3

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

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

4

1 回答 1

5

您必须提供绝对路径或使用~指示主目录的路径。引自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-09-07T03:49:44.797 回答