我目前正在通过命令行使用 git。每次推送或拉取存储库时,我都需要 git 询问用户名和密码。目前它只要求输入密码。请在这里帮助我。
.git/config
文件中的url有点像这样:
https://[email protected]/hello/folder.git
在拉/推之前取消设置凭证。
$ git config --unset credential.helper
$ git pull
通过 ssh 使用 git 而不是 https 是进行无密码身份验证的一种方法。
步骤(大致)涉及;
ssh-keygen -t rsa
,将密码留空)这些说明复制
~/.ssh/id_rsa.pub
我承认设置需要一些麻烦 - 但一旦完成,您就不必在该 PC 上再次执行此操作。也就是说,您可以克隆 github 上的任何其他存储库(使用 ssh 克隆),而无需输入任何密码。
git push https://github.com/user_name/repo_name.git
然后输入你的ID和密码
您必须输入 user_name 和 repo_name。
您已表明您正在使用的网址是:
您已将您的用户名放入 URL 中。 URL 的
xxxxx
部分是您要用于身份验证的用户名。由于您已经提供了它,Git 不会提示您提供它。但是,它会提示您输入密码(尽管您也可以将其包含在 URL 中,格式为 https://xxxxx:[email protected]/hello/folder.git
)。
如果您希望系统提示您输入用户名 和 密码,只需将其从 URL 中删除即可:
设置凭证助手对我有用。
只需输入以下内容并按 Enter 键:
git config --global credential.helper store
**面对相同的问题尝试使用这两个命令解决**
git config --global credential.https://github.com.username username
git config --global credential.https://github.com.email [email protected]
尝试使用这两个命令 用户名 => 您个人资料的实际用户名
[电子邮件受保护] => 实际 github 帐户电子邮件