【问题标题】:Clone a repo with Slash in Password用密码中的斜线克隆一个 repo
【发布时间】:2014-07-14 17:22:08
【问题描述】:

可以使用

克隆一个 repo
git clone https://username:password@github.com/username/repository.git

但是,当密码包含正斜杠时,这不起作用。错误是:

error: Couldn't resolve host 'klaus777:password' while accessing 
https://klaus777:password/.@bitbucket.org/romeo/server-code.git/info/refs

fatal: HTTP request failed

如果我对斜线进行 URL 编码,则会收到以下错误:

error: The requested URL returned error: 401 while accessing 
https://klaus777:password%2F%2E@bitbucket.org/romeo/server-code.git/info/refs

fatal: HTTP request failed

因此,问题是:您如何处理密码中的正斜杠?

附言。如果我从 URL 中删除密码并在出现提示时提供密码,一切正常。

【问题讨论】:

    标签: git passwords clone


    【解决方案1】:

    正斜杠的percent encoding 应该是%2F,检查您是否需要编码您似乎包含在密码中的'.' (%2E) .

    https://klaus777:password%2F.@bitbucket.org/romeo/server-code.git
    

    但这似乎不适用于 GitHub:OP Klaus 确认 in the comments

    我更改了密码。

    【讨论】:

    • 不幸的是,仅编码正斜杠也不起作用。
    • @Klaus 无需对 '.' 进行编码(无保留字符)。但是对于测试,您能否检查一下“/”是否会更好? %252F%25252F
    • @Klaus 并确保您没有在 GitHub 上为您的帐户激活 2FA(2 表单身份验证),因为这样您就必须生成一个令牌作为密码,而不是使用您的常规帐户密码.
    • 我放弃了。我更改了密码。不幸的是,这些建议也没有奏效。
    • @Klaus 好的,我已将您的结论包含在答案中以提高知名度。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-07
    • 1970-01-01
    • 2017-08-30
    • 1970-01-01
    • 1970-01-01
    • 2012-04-15
    相关资源
    最近更新 更多