Git 失败,出现 > 致命错误。无法读取用户名
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/47997966/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git failed with a > fatal error. could not read Username for
提问by danbord
I've been struggling with that issue for a couple days now.
我已经为这个问题苦苦挣扎了几天了。
I'm unable to connect to my Git project (stored in VisualStudio.com) from a specific computer (it works on my second PC). Whenever I try to Sync or Clone my repository, VS2017 asks for my user credentials (twice) and the I get the following error :
我无法从特定计算机(它在我的第二台 PC 上运行)连接到我的 Git 项目(存储在 VisualStudio.com 中)。每当我尝试同步或克隆我的存储库时,VS2017 都会要求我提供用户凭据(两次),并且出现以下错误:
Error: cannot spawn askpass: No such file or directory Error encountered while cloning the remote repository: Git failed with a fatal error. could not read Username for 'https://.visualstudio.com': terminal prompts disabled
错误:无法生成 askpass:没有这样的文件或目录 克隆远程存储库时遇到错误:Git 因致命错误而失败。无法读取“https://.visualstudio.com”的用户名:终端提示已禁用
Can't remember if I changed anything that could've caused that...
不记得我是否改变了可能导致这种情况的任何东西......
回答by Marina Liu
It's mainly caused by the credentials have been remembered by Credential Manager. You should remove the credentials for xxx.visualstudio.com which have been stored in Credential Manager.
这主要是由于凭据管理器已记住凭据引起的。您应该删除存储在凭据管理器中的 xxx.visualstudio.com 凭据。
Such as if the pc's OS is windows, you can open Credential Manager -> Windows Credentials -> under Generic Credentials -> remove the credentials like git:https://xxx.visualstudio.com.
比如电脑的操作系统是windows,你可以打开Credential Manager -> Windows Credentials -> Generic Credentials -> 删除像git这样的凭据:https: //xxx.visualstudio.com。
Then clone again, git will let you input the credential for the repo. After inputing the username(email address) and password which can access the VSTS account, the repo should be cloned successful.
然后再次克隆,git 会让你输入 repo 的凭证。输入可以访问VSTS帐户的用户名(电子邮件地址)和密码后,应该可以成功克隆repo。
回答by Matstar
I did not have any git credentials registered with Windows Credentials and I still received this error, even after selecting my windows user account in the VS User Dialog popup.
我没有使用 Windows 凭据注册任何 git 凭据,即使在 VS 用户对话框弹出窗口中选择了我的 Windows 用户帐户后,我仍然收到此错误。
After a day of trying different things like re-installing GIT for windows, I managed to fix this issue by deleting a this file: "C:\Users(profile)\AppData\Local\GitCredentialManager\tenant.cache".
经过一天的尝试不同的事情,比如重新安装 Windows 的 GIT,我设法通过删除这个文件来解决这个问题:“C:\Users(profile)\AppData\Local\GitCredentialManager\tenant.cache”。
On the next retry, a GIT entry showed up in my Windows Credentials generic list. See Issue
在下一次重试时,我的 Windows 凭据通用列表中出现了一个 GIT 条目。见问题
回答by Lachezar Lalov
Simply update your Visual Studio to the latest version. This bug was reported and fixed with the latest updates. Worked for me.
只需将您的 Visual Studio 更新到最新版本。此错误已通过最新更新报告并修复。对我来说有效。
回答by MikeZ
I had a similar problem.
我有一个类似的问题。
Push from within VS2017 would fail, I was getting an error spawning git-askpass.exe
从 VS2017 内推送会失败,我在生成 git-askpass.exe 时遇到错误
I fixed it by copying/replacing all the files in the VS2017 git-core folder with the files from the git-core folder created by the Git installation.
我通过使用 Git 安装创建的 git-core 文件夹中的文件复制/替换 VS2017 git-core 文件夹中的所有文件来修复它。
I might have only needed the new git-credential-manager.exe, but I replaced everything.
我可能只需要新的 git-credential-manager.exe,但我替换了所有内容。
So far, no problems.
到目前为止,没有问题。
VS2017 folder: C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\git-core
VS2017 文件夹:C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\git-core
Git installation folder: C:\Program Files\Git\mingw64\libexec\git-core
Git安装文件夹:C:\Program Files\Git\mingw64\libexec\git-core
回答by Tahir Khalid
Okay after much heartache I managed to resolve the issue (at this point had I tried everything including deleting accounts from Credential Manager).
好吧,经过很多心痛,我设法解决了这个问题(此时我尝试了所有方法,包括从凭据管理器中删除帐户)。
I started up Visual Studio 2017 and then I opened my repository and next went to the Team Explorertab for the repository.
我启动了 Visual Studio 2017,然后打开了我的存储库,然后转到存储库的团队资源管理器选项卡。
I left-clicked on the Sync option and then again on the sync link button to initiate the pull/push actions. This caused Visual Studio to display a dialog box asking me to select my credentials.
我左键单击同步选项,然后再次单击同步链接按钮以启动拉/推操作。这导致 Visual Studio 显示一个对话框,要求我选择我的凭据。
However what I did to resolve the issue was to first "Forget" the account that I was trying to use in the first place (left-click on the 3 dot icon on the right) and then I was prompted for the username and password again - enter the correct one's and it should all sync up nicely now!
但是,我为解决该问题所做的是首先“忘记”我最初尝试使用的帐户(左键单击右侧的 3 点图标),然后再次提示我输入用户名和密码- 输入正确的,现在应该可以很好地同步了!
回答by Alec McTavish
The combination of clearing credentialsand deleting tenant.cachehas worked for me in the past - I was able to force a reconnect to my *.visualstudio.com git repo and get things working entirely from within VS2017. Had to do more today with a new VS2019 install though. Key in my case was "terminal prompts disabled" portion of the error (similar to Anuranjan Srivastav's comment on the accepted answer). Doing a simple "git fetch" using command line tools (after clearing out credentials) did the trick for me this time - prompt for credentials came up and all was set aright.
清除凭据和删除tenant.cache的组合在过去对我有用 - 我能够强制重新连接到我的 *.visualstudio.com git repo 并在 VS2017 中完全运行。不过,今天必须通过新的 VS2019 安装来完成更多工作。在我的情况下,关键是错误的“终端提示已禁用”部分(类似于 Anuranjan Srivastav 对已接受答案的评论)。这次使用命令行工具(清除凭据后)执行简单的“git fetch”对我来说很有效 - 提示输入凭据并且一切设置正确。
回答by Ziggler
In my case this happened when my VS 2019 license expired. I approached helpdesk and they gave a new license and then I activated it and when I tried to Fetch using VS 2019 the problem started. I got below error message when I did Fetch in VS 2019.
就我而言,这发生在我的 VS 2019 许可证过期时。我联系了帮助台,他们给了一个新的许可证,然后我激活了它,当我尝试使用 VS 2019 获取时,问题开始了。我在 VS 2019 中执行 Fetch 时收到以下错误消息。
Git failed with a fatal error. could not read Username for 'https://xxx.visualstudio.com': terminal prompts disabled
Git 因致命错误而失败。无法读取“ https://xxx.visualstudio.com”的用户名:终端提示已禁用
Below are the steps I did
下面是我做的步骤
1) I went to Credential Manager and deleted the entry for https://xxx.visualstudio.com.
1) 我去了 Credential Manager 并删除了https://xxx.visualstudio.com的条目。
2) Installed GIT Credential Manager for Windows. https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases
2) 为 Windows 安装了 GIT 凭证管理器。https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases
3) Open command prompt and went to my local working directory.
3)打开命令提示符并转到我的本地工作目录。
4) Gave command git fetchand pressed enter and I got few messages that said Fetch was success.
4) 给出命令git fetch并按回车键,我收到几条消息说 Fetch 成功。
5) Re-opened VS 2019 and did Fetch and now it worked. I also tested Pull, Push and so on and everything works.
5) 重新打开 VS 2019 并执行 Fetch,现在它可以工作了。我还测试了拉、推等,一切正常。
回答by Kush
I had a similar problem.
我有一个类似的问题。
I solved it by the following steps:
我通过以下步骤解决了它:
- Connect to your remote Azure DevOps repository from Git Bash.
- Try Git commands for Sync/Clone/Pull/Push (ing) the repository.
- Git Credential Manager will ask the user credentials (twice in my case). Provide the details.
- It will ask for Username and Password credentials
- This Username and Password can be generated from here (Clone -> Generate GIT Credentials):
- Try Git operations from Visual Studio. (It should work)
- 从 Git Bash 连接到远程 Azure DevOps 存储库。
- 尝试 Sync/Clone/Pull/Push (ing) 存储库的 Git 命令。
- Git Credential Manager 将询问用户凭据(在我的情况下两次)。提供详细信息。
- 它将要求提供用户名和密码凭据
- 可以从这里生成此用户名和密码(克隆 -> 生成 GIT 凭据):
- 从 Visual Studio 尝试 Git 操作。(它应该工作)
Please note that it will ask for Username Password every time you perform any of the Git operations (pull/push/fetch/clone etc).
请注意,每次执行任何 Git 操作(pull/push/fetch/clone 等)时,它都会要求输入用户名密码。
I solved it by the following:
我通过以下方式解决了它:
Run
跑
git config --global credential.helper store
then run
然后运行
git pull
provide a username and password. These details will then be remembered.
提供用户名和密码。这些细节会被记住。
回答by Prageeth godage
I had the same issue and doesn't fix doing anything above and fixed by doing following,
我遇到了同样的问题,没有解决上面的任何问题,而是通过执行以下操作来解决,
1)go to souce code location ===> .git folder ==>config file ==> open it.
1) 转到源代码位置 ===> .git 文件夹 ==> 配置文件 ==> 打开它。
2)go to [remote "origin"] url ="dev.azure.com/xxxx/_git/yyyy" copy that url
2)转到[远程“来源”] url ="dev.azure.com/xxxx/_git/yyyy" 复制该网址
3)open the fresh browser [icongnito :)] open the copied url.
3)打开新浏览器 [icongnito :)] 打开复制的 url。
4)It ask to login just login from your commiting credential.
login and go to files and click on clone button.you see in image
4)它要求登录,只需从您的提交凭据登录即可。登录并转到文件并单击克隆按钮。您在图像中看到
5)without doing any modification to that url.you may wonder that your user name is not there in prefix.but dont worry copy with that username.
5) 不对该 url 进行任何修改。您可能想知道您的用户名不在前缀中。但不要担心使用该用户名复制。
6)past that URL in step 2 location.
6) 在第 2 步的位置经过那个 URL。
7)I also remove C:\Users(profile)\AppData\Local\GitCredentialManager\tenant.cache file [added later] it works at least for me.
7)我还删除了 C:\Users(profile)\AppData\Local\GitCredentialManager\tenant.cache 文件 [稍后添加] 它至少对我有用。
Side note : anyone know why that url prefix with site created user name instead of my user name ?
旁注:有人知道为什么用站点创建的用户名而不是我的用户名的 url 前缀吗?
回答by Abhishek Agrawal
Updating git to latest version and running in Administrator command window helped me
将 git 更新到最新版本并在管理员命令窗口中运行对我有帮助