使用带有用户和密码的 http 进行 Git 克隆
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6030698/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git clone using http with user and password
提问by Bernd Klaus
I try to use git clone http://user:[email protected]but I have some problems with adding user or password because the user is using email which contains an other @ and password is using an esclamation mark ( ! )
我尝试使用 git clone http://user:[email protected]但我在添加用户或密码时遇到了一些问题,因为用户使用的电子邮件包含另一个 @,而密码使用了感叹号 (!)
the command looks like http://[email protected]:[email protected]/git
该命令看起来像http://[email protected]:[email protected]/git
This is not working - I tried 0x21password instead of !password but the system don't except this.
这是行不通的 - 我尝试了 0x21password 而不是 !password 但系统不会除此之外。
Any idea?
任何的想法?
采纳答案by Russell Troywest
回答by ajay.gour
This is pretty old question but let me add the workaround for benefits of others. We recently started using email id as username to connect to Git, but pull/fetch/push etc commands started failing. We tried %40 as suggested in previous comments but it didnt work. So we created ~/.netrc file with following information.
这是一个很老的问题,但让我添加解决方法以造福他人。我们最近开始使用电子邮件 ID 作为用户名连接到 Git,但是 pull/fetch/push 等命令开始失败。我们按照之前评论中的建议尝试了 %40,但没有奏效。所以我们创建了 ~/.netrc 文件,其中包含以下信息。
machine git.myserver.com login [email protected] password mypassword
机器 git.myserver.com 登录 [email protected] 密码 mypassword
We also removed username from the url which gets stored in .git/config file. And we could now do pull/commit etc. Its not advisable to use this approach because password is stored in plain text in a file but that was a quick workaround to make urgent commit while looking for ways to connect using email id from command line tool.
我们还从存储在 .git/config 文件中的 url 中删除了用户名。我们现在可以执行 pull/commit 等操作。不建议使用这种方法,因为密码以纯文本形式存储在文件中,但这是一种快速解决方法,可在寻找使用命令行工具中的电子邮件 ID 进行连接的同时进行紧急提交.