git http通过WebDAV推送 - 如果我的用户名中有"@"怎么办?

kbr*_*bro 4 git webdav git-push

我的网络托管服务提供商让我通过WebDAV访问我的网站空间,所以我想我会在那里设置一个git存储库,看看会发生什么.克隆存储库只读工作正常,因为"git clone http://my.server.com/repo.git "只使用标准的HTTP传输.

当我尝试使用WebDAV时出现问题,因为我的用户ID是"user@my.server.com",我必须使用端口2077.这意味着我必须做类似的事情

git config remote.origin.pushurl http://user@my.server.com@my.server.com:2077/repo.git
Run Code Online (Sandbox Code Playgroud)

并且URL中的两个@符号必须导致问题,因为"git push origin master"报告"错误22".

我尝试创建.netrc文件条目

machine    my.server.com
login      user@my.server.com
password   ****
Run Code Online (Sandbox Code Playgroud)

但这似乎没有帮助.

我也尝试用"%","\ @"和"%40"替换第一个"@",但没有一个有效.

小智 5

当前版本的git不会处理用户名和密码中的百分比失误.我昨天提交了一个修补程序来修复此问题(至少对于HTTP URL),因此可能很快就会修复.使用该补丁,您应该能够访问WebDAV:

git config remote.origin.pushurl http://user%40my.server.com@my.server.com:2077/repo.git

但是,在我编写本文时,您可能还有另一个与libcurl> 7.16(请参阅"git help http-push"中的注释)相关的问题.


Von*_*onC 1

如果 WebDAV 使用的 URI 确实遵循统一资源标识符 (URI):通用语法( rfc3986 ),则不应@userinfo

 authority     = [ userinfo "@" ] host [ ":" port ]
 userinfo      = *( unreserved / pct-encoded / sub-delims / ":" )
 pct-encoded   = "%" HEXDIG HEXDIG

 unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
 sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
               / "*" / "+" / "," / ";" / "="


 reserved      = gen-delims / sub-delims
 gen-delims    = ":" / "/" / "?" / "#" / "[" / "]" / "@"
Run Code Online (Sandbox Code Playgroud)

那么你尝试过吗http://user@my.server.com:2077/repo.git