Git存储库URL - 没有绝对路径的SSH语法 [英] Git repository URL - SSH syntax without absolute path

查看:431
本文介绍了Git存储库URL - 没有绝对路径的SSH语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个可通过SSH在自定义端口上访问的git存储库服务器(比如说12345)。我发现在这种情况下,存储库URL需要使用SSH语法来指定:

  git clone ssh:// login @ server.com:12345/absolute/path/to/repository 

我想设置它这样,用户就可以在不指定绝对路径的情况下克隆存储库。

  git clone ssh://login@server.com:12345 / repository.git 

我研究过主题,并找到以下选项:


  1. 从URL中删除自定义端口,并使用户将其添加到 〜/ .ssh / config 文件(最后一种解决方法,而不是解决方案)。
  2. 删除SSH并使用 git-daemon 并指定它的 - base-path 参数(仍然是一种解决方法...)

  3. 使用像 gitosis gitolite 这样的实用程序 - 但是, NLY? Gitosis已停止使用,gitolite是一款相当庞大的软件...



  4. 我想要的是一个漂亮的SSH网址端口(这样我可以分发整个 git clone 命令并且不需要远程用户)。上面哪个解决方案对我来说是最可行的?

    如果您使用<$ c的替代形式$ c> ssh 你不需要绝对路径。例如...

    pre $ g $ git clone lars@myserver.example.com:repos / myrepo.git
    code>

    ...将克隆库 repos / myrepo.git 相对于我的主目录,尽管这不允许使用备用端口。但是,您也可以使用来指定用户的主目录,例如: git clone ssh://login@server.com:12345 /〜/ repository.git

    顺便说一句,尽管停止了, gitosis 功能相当好,代码既小又易于理解。它提供了一套有用的访问控制和存储库的自助式管理。我不会完全打折。


    I'm running a git repository server accessible via SSH, on a custom port (let's say 12345). I have found that in this case the repository URLs need to be specified using SSH syntax:

    git clone ssh://login@server.com:12345/absolute/path/to/repository
    

    I'd like to setup it in such a way that it would be possible for users to clone repositories without specifying the absolute path.

    git clone ssh://login@server.com:12345/repository.git
    

    I have researched the topic and found the following options:

    1. Remove the custom port from the URL and make the users add it to their ~/.ssh/config file (a last-resort workaround rather than a solution).
    2. Drop SSH and use git-daemon and specify its --base-path parameter (still a workaround...)
    3. Use an utility like gitosis or gitolite - but wouldn't it be an overkill to use it for this purpose only? Gitosis is discontinued, gitolite is a quite huge piece of software...

    All I want is a "prettier" SSH URL with custom port (so I can distribute the whole git clone command and require nothing more from the remote user). Which one of the above solutions would be the most viable in my case?

    解决方案

    If you use the alternate form of ssh URLs you don't need an absolute path. For example...

    git clone lars@myserver.example.com:repos/myrepo.git
    

    ...will clone repository repos/myrepo.git relative to my home directory, although this doesn't permit use of an alternate port. However, you can also use ~ in either form to indicate the user's home directory, e.g.:

    git clone ssh://login@server.com:12345/~/repository.git
    

    Incidentally, despite being discontinued, gitosis functions quite well, and the code is both small and easy to understand. It offers a useful set of access controls and self-service management of repositories. I wouldn't discount it completely.

    这篇关于Git存储库URL - 没有绝对路径的SSH语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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