【问题标题】:Git clone with password @带有密码@的Git克隆
【发布时间】:2014-11-27 00:14:18
【问题描述】:

我需要转义使用密码的@,因为它与主机混淆。

示例 1: git clone https://user:p@ssword@github.com/user/repo.git

当我运行上面的例子时,它是错误的,因为密码有@,他明白下一个参数是主机。尝试使用 \ 转义,或者您可以使用 "" 之间的 url 但它不是。

示例 2: (echo user; echo p@ssword) | git clone https://github.com/usuario/repo.git

当我只使用命令时,git clone https://github.com/usuario/repo.git他会询问用户和密码,所以我使用了上面的命令,这与我只使用一行更改root密码相同。

【问题讨论】:

    标签: git shell github command-line escaping


    【解决方案1】:

    我认为您正在寻找的是转义特殊字符@,您可以使用编码%40 而不是@。这个链接可能对Escape @ character in git proxy password

    有帮助

    【讨论】:

    • 完美\%40 谢谢
    【解决方案2】:

    您可以将 @ 替换为其 URL 编码格式 %40

    如果您的密码是 password@99。将其更改为 password%4099

    git clone https://username:password%4099@bitbucket.org/sarat.git
    

    【讨论】:

      【解决方案3】:

      查看链接Git Configure

      在本地配置你的 git 帐户 -

      git config --global user.name myName

      git config --global user.email myEmail

      以下命令会将您的密码保存在内存中一段时间​​。

      $ git config --global credential.helper cache

      设置 git 使用凭证内存缓存

      $ git config --global credential.helper 'cache --timeout=3600'

      将缓存设置为 1 小时后超时(设置以秒为单位)

      希望对你有帮助

      【讨论】:

      • 这并不表示如何转义字符。
      猜你喜欢
      • 2021-03-18
      • 1970-01-01
      • 2014-07-30
      • 1970-01-01
      • 2015-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多