【问题标题】:How can I escape `@` of password in git URL如何在 git URL 中转义密码的“@”
【发布时间】:2017-06-24 07:25:57
【问题描述】:

借口:
我看到了这个:Escape @ character in git proxy password 但它是关于http.proxy 参数的,而p%4055 对url 参数不起作用。

我的问题:
我使用 git 版本 1.7.1
我的密码库是:p@55
我使用gitlab 服务器和centos 作为客户端。
在.git/config 文件中,我是这样的:

[remote "origin"]
url = http://user:p@55@domain.com:port/repo.git

但是当我拉它的时候,给了我这个错误:

error: Couldn't resolve host '55:domain.com' while accessing ...

我知道逃逸@ char,但是:

我试试p\@55,给我这个错误:

fatal: bad config file line 8 in .git/config

我试试p%4055,给我这个错误:

error: The requested URL returned error: 401 while accessing ...

【问题讨论】:

  • 使用http://user:p%4055@domain.com:port/repo.git
  • @TimBiegeleisen 我明白了,但那是http.proxy 参数,我尝试%40 并且不适用于url 参数。
  • @TimBiegeleisen As 你可以看到我关于尝试p%4055 的问题的结尾,但不起作用!
  • 你使用的是什么版本的 Git? (本地和远程服务器上)

标签: git escaping


【解决方案1】:

我刚刚将 git 版本从 1.7.1 升级到 2.11.1,这对我有用:

url = http://user:p%4055@domain.com:port/repo.git

【讨论】:

    【解决方案2】:

    尝试使用@ - (%40) 符号的 URL 编码值。

    你的例子:

    网址 = http://user:p%4055@domain.com:port/repo.git

    编辑:

    如果上述方法不起作用,请使用以下方法:

    sshpass -p 密码 git clone ssh://username@onboard.com/srv/git/repo

    【讨论】:

    • 正如我在关于p%4055 的问题的结尾所说的那样,给我错误......所以,正如我所说,我想要 git pull,而不是克隆!所以我不想在 CLI 中使用它,我想放在配置文件中。
    • 我又添加了一种方法 sshpass
    • 我想放入配置文件,我不想在 CLI 下使用。我也想做 git pull 而不是 git clone!,所以 http 协议不是 ssh ....
    • sshpass -p p@55 git pull 成功了。但正如我所说,我想配置 git 配置文件。原因之一是任何人都可以在历史上显示密码。
    【解决方案3】:

    【讨论】:

      猜你喜欢
      • 2011-09-04
      • 2011-04-06
      • 1970-01-01
      • 1970-01-01
      • 2013-06-18
      • 2021-12-29
      • 2014-10-06
      • 1970-01-01
      相关资源
      最近更新 更多