【问题标题】:How to authenticate with credentails while cloning a Git repository如何在克隆 Git 存储库时使用凭据进行身份验证
【发布时间】:2017-03-16 05:13:04
【问题描述】:

我正在使用以下 GIT bash 命令从 GIT 远程存储库下载文件。我的一些 GIT 存储库无需 SSO 身份验证即可访问,其中一些通过 SSO 身份验证。我的 git bash 命令仅适用于其中的存储库不需要 SSO 身份验证。

我想知道如何将我的 SSO 凭据提供给以下命令。

   git init
   git config --global http.sslVerify false
   git pull https://github-cloudcreations.orange.cloud.corp.myDomain.com/DoaminCloud/myrepo.git DEVELOPMENT

【问题讨论】:

    标签: git bash


    【解决方案1】:

    请注意:出于安全原因,您不应该这样发布您的 GIT 存储库的 URL。

    现在,如果我正确理解了您的问题,那么无论何时从 git 存储库推送或拉取,您都不需要进行身份验证(输入您的用户名和密码)。

    每次都必须进行身份验证的最简单方法是通过 ssh 而不是 http 使用 git。

    基本上,导入你的 git 仓库

    git checkout git@github-cloudcreations.orange.cloud.corp.myDomain.com/DoaminCloud/myrepo.git
    

    或者如果你已经在 http 中有你的 repo,你可以使用命令更新远程 URL

    git remote set-url origin git@github-cloudcreations.orange.cloud.corp.myDomain.com/DoaminCloud/myrepo.git
    

    【讨论】:

    • 在 ssh 上使用 git,并将客户端的公钥添加到远程服务器上的已知主机(ssh-copy-id),这样 ssh 就不会提示输入密码。
    • 我必须先使用我的 SSO 凭据进行身份验证才能访问 git 存储库。我只想知道在尝试从 git bash 访问 git 时如何使用我的凭据进行身份验证。
    【解决方案2】:

    如果您想使用 https 网址(而不是 ssh 网址),您可以使用:

    git ls-remote https://....
    

    这将要求您提供凭据。

    确保首先设置一个 credential helper,它将为您缓存这些用户名/密码。

    然后你可以 git clone/pull 而无需再次输入它们。

    【讨论】:

      猜你喜欢
      • 2017-02-21
      • 1970-01-01
      • 2022-10-17
      • 1970-01-01
      • 2020-10-24
      • 2018-09-11
      • 2016-07-18
      • 2016-04-16
      • 2020-10-19
      相关资源
      最近更新 更多