【问题标题】:Is there a way to clone from gitlab with username and passwordr in one command?有没有办法在一个命令中使用用户名和密码从 gitlab 克隆?
【发布时间】:2018-02-20 18:33:34
【问题描述】:

这篇文章中的这个解决方案不起作用How to provide username and password when run "git clone git@remote.git"?

git clone https://username:password@github.com/username/repository.git

致命:无法访问'http://..:无法解析主机:用户名

【问题讨论】:

    标签: git bash gitlab git-bash


    【解决方案1】:

    Gitlab 不支持在一行中使用 http 进行克隆。也许你可以用 ssh 来做?

    有一些 git 服务可以在一行中使用 http 克隆。例如 Github 和 Gitorious。 我认为 Gitlab 只支持用户名前缀。总是会询问密码。这也带来了巨大的安全优势,因为通过这种方式,您的密码永远不会存储在日志文件中。

    【讨论】:

    • 感谢您的详细解答
    【解决方案2】:

    是的,你可以。语法是:

    git clone https://username:token@gitlab.com/user/repo.git
    

    username 是您的 Gitlab 用户名,token 是通过您的 gitlab 的 settings > Access Tokens

    生成的

    【讨论】:

      猜你喜欢
      • 2022-10-13
      • 2015-11-26
      • 2018-07-05
      • 1970-01-01
      • 1970-01-01
      • 2022-01-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多