每次我拉或推Git时要求输入用户名和密码
问题描述:
我目前通过命令行使用git。每次我推或拉我的存储库时,我都需要git来询问用户名和密码。目前它只是要求输入密码。请在这里帮助我。在.git/config
文件的URL是有点像这样:每次我拉或推Git时要求输入用户名和密码
https://[email protected]/hello/folder.git
答
通过ssh来代替https使用Git是有密码认证的一种方式。
Here is a github manual page on the topic.
步骤(粗略地)涉及;
- 创建您自己的SSH密钥(
ssh-keygen -t rsa
,密码留空) - 添加该公钥github上(复制
~/.ssh/id_rsa.pub
内容按these instructions - 使用ssh克隆你的仓库,而不是HTTPS的。
我承认需要一点儿摆弄才能建立起来 - 但一旦完成,您就不必再在PC上重做了。也就是说,您可以在github上克隆任何其他repo(使用SSH克隆)而不需要输入任何密码。
答
在推/拉之前取消设置凭证。
$ git config --unset credential.helper
$ git pull
+0
这不起作用:( – Mithila
+0
尝试'git config --unset credential.helper' –
如果您使用ssh而不是https访问git存储库,则可以使用ssh密钥而不是交互式身份验证来跳过身份验证。 – Shadow
[在GitHub上使用https://时有没有办法跳过密码输入?](http://stackoverflow.com/questions/5343068/is-there-a-way-to-skip-password-使用https-on-github时键入) – Shadow
如何使用ssh? – Mithila