每次拉或推 Git 时都询问用户名和密码

问题描述 投票:0回答:6

我目前正在通过命令行使用 git。每次推送或拉取存储库时,我都需要 git 询问用户名和密码。目前它只要求输入密码。请在这里帮助我。

.git/config
文件中的url有点像这样:

https://[email protected]/hello/folder.git
git github ubuntu-14.04
6个回答
1
投票

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

$ git config --unset credential.helper

$ git pull

0
投票

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

这是有关该主题的 github 手册页。

步骤(大致)涉及;

  1. 创建您自己的 ssh 密钥(
    ssh-keygen -t rsa
    ,将密码留空)
  2. 将该公钥添加到 github(按照
    这些说明
    复制 ~/.ssh/id_rsa.pub
  3. 的内容)
  4. 使用 ssh 而不是 https 克隆存储库。

我承认设置需要一些麻烦 - 但一旦完成,您就不必在该 PC 上再次执行此操作。也就是说,您可以克隆 github 上的任何其他存储库(使用 ssh 克隆),而无需输入任何密码。


0
投票
git push https://github.com/user_name/repo_name.git

然后输入你的ID和密码

您必须输入 user_name 和 repo_name。


0
投票

您已表明您正在使用的网址是:

https://[电子邮件受保护]/hello/folder.git

您已将您的用户名放入 URL 中。 URL 的

xxxxx
部分是您要用于身份验证的用户名。由于您已经提供了它,Git 不会提示您提供它。但是,它会提示您输入密码(尽管您也可以将其包含在 URL 中,格式为
https://xxxxx:[email protected]/hello/folder.git
)。

如果您希望系统提示您输入用户名 密码,只需将其从 URL 中删除即可:

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


0
投票

设置凭证助手对我有用。
只需输入以下内容并按 Enter 键:

git config --global credential.helper store


0
投票

**面对相同的问题尝试使用这两个命令解决**

git config --global credential.https://github.com.username username
git config --global credential.https://github.com.email [email protected]

尝试使用这两个命令 用户名 => 您个人资料的实际用户名

[电子邮件受保护] => 实际 github 帐户电子邮件

© www.soinside.com 2019 - 2024. All rights reserved.