每次我拉或推Git时都要求输入用户名和密码

时间:2017-02-27 04:59:09

标签: git github ubuntu-14.04

我目前正在通过命令行使用git。每次推送或拉出我的存储库时,我都需要git来询问用户名和密码。目前它只是要求输入密码。请帮帮我。 .git/config文件中的网址有点像这样:

https://xxxxx@github.com/hello/folder.git

4 个答案:

答案 0 :(得分:1)

在拉/推之前取消设置凭证。

$ git config --unset credential.helper

$ git pull

答案 1 :(得分:0)

通过ssh而不是https使用git是进行无密码身份验证的一种方法。

Here is a github manual page on the topic.

步骤(大致)涉及;

  1. 创建自己的ssh密钥(~/.ssh/id_rsa.pub,将密码留空)
  2. 将该公钥添加到github(根据these instructions
  3. 复制{{1}}的内容
  4. 使用ssh而不是https克隆您的存储库。
  5. 我承认需要花点时间才能设置好 - 但是一旦完成,你就不应该再在那台PC上做了。也就是说,您可以在github上克隆任何其他repo(使用ssh clone),而无需键入任何密码。

答案 2 :(得分:0)

git push https://github.com/user_name/repo_name.git

然后输入您的ID和密码

您必须输入的用户名和仓库名称。

答案 3 :(得分:0)

您已表明您使用的URL是:

  

https://xxxxx@github.com/hello/folder.git

您已将用户名放入URL 。 URL的xxxxx部分是您要用于身份验证的用户名。由于您已经提供了它,因此Git不会提示您输入它。但是,它会提示您输入密码(尽管您也可以使用https://xxxxx:password@github.com/hello/folder.git的形式将其包含在URL中)。

如果要提示您输入用户名密码,只需将其从URL中删除:

  

https://github.com/hello/folder.git

相关问题