Git不断提示我输入密码 [英] Git keeps prompting me for a password

查看:508
本文介绍了Git不断提示我输入密码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经使用Git一段时间了,但是不断要求输入密码的人开始把我推向高潮.

I've been using Git for a while now, but the constant requests for a password are starting to drive me up the wall.

我正在使用Mac OS X和GitHub,并按照GitHub

I'm using Mac OS X and GitHub, and I set up Git and my SSH keys as instructed by GitHub's Set Up Git page.

我还在我的Mac OS X钥匙串中添加了github SSH密钥,如

I've also added the github SSH key to my Mac OS X keychain, as mentioned on GitHub's SSH key passphrases page. My public key is registered with Git.

尽管如此,每次我尝试Git pull时,都必须输入我的用户名和密码.除了此以外,我还需要设置SSH密钥吗?

Nevertheless, every time I try to Git pull, I have to enter my username and password. Is there something other than an SSH key that I need to set up for this?

推荐答案

我认为您可能使用了错误的Git存储库URL.

I think you may have the wrong Git repository URL.

打开.git/config并找到[远程来源"]部分.确保您使用的是SSH:

Open .git/config and find the [remote "origin"] section. Make sure you're using the SSH one:

ssh://git@github.com/username/repo.git

如果单击克隆或下载并选择 ssh ,则可以在存储库的主页中看到SSH URL.

You can see the SSH URL in the main page of your repository if you click Clone or download and choose ssh.

而不是httpsgit一个:

https://github.com/username/repo.git
git://github.com/username/repo.git

您现在可以使用 just 验证SSH密钥而不是用户名和密码.

You can now validate with just the SSH key instead of the username and password.

如果Git抱怨'origin' has already been added,请打开.config文件并在[remote origin]之后将url = "..."部分编辑为url = ssh://github/username/repo.git

If Git complains that 'origin' has already been added, open the .config file and edit the url = "..." part after [remote origin] as url = ssh://github/username/repo.git

其他服务也是如此.确保地址看起来像:protocol://something@url

The same goes for other services. Make sure the address looks like: protocol://something@url

例如 Azure DevOps的.git/config:

E.g. .git/config for Azure DevOps:

[remote "origin"]
    url = https://mystore@dev.azure.com/mystore/myproject/
    fetch = +refs/heads/*:refs/remotes/origin/*

这篇关于Git不断提示我输入密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆