尝试推送 git 并收到“无法读取‘https://github.com’的用户名:终端提示已禁用”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/42915793/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:54:02  来源:igfitidea点击:

Attempting push on git and receiving "could not read Username for 'https://github.com': terminal prompts disabled"

gitvisual-studiogithub

提问by Matt

I'm using Visual Studio, and the GitHub Extension. I am able to sign in, then clone my team's repository, and then pull changes successfully.

我正在使用 Visual Studio 和 GitHub 扩展。我能够登录,然后克隆我团队的存储库,然后成功拉取更改。

When it comes time to push my changes back to remote, I get a blank command prompt appear on the screen briefly, and then the following errors in the output window:

当需要将我的更改推送回远程时,我会在屏幕上短暂出现一个空白的命令提示符,然后在输出窗口中出现以下错误:

Error encountered while pushing to the remote repository: Git failed with a fatal error.

fatal: AggregateException encountered. One or more errors occurred.

error: cannot spawn askpass: No such file or directory

fatal: could not read Username for 'https://github.com': terminal prompts disabled

推送到远程存储库时遇到错误:Git 因致命错误而失败。

致命:遇到 AggregateException。发生了一个或多个错误。

错误:无法生成 askpass:没有这样的文件或目录

致命:无法读取“ https://github.com”的用户名:终端提示已禁用

EDIT: pushing via the command line works, as does pushing via the GitHub desktop application, just not within this extension.

编辑:通过命令行推送和通过 GitHub 桌面应用程序推送一样有效,只是不在此扩展中。

Any ideas why this might be happening? I can't see why it needs the Username given that I have signed into the extension.

任何想法为什么会发生这种情况?鉴于我已登录扩展程序,我不明白为什么它需要用户名。

采纳答案by Taylor Ackley

As per my comment. You can include your username in the remote URL (similar to FTP).

根据我的评论。您可以在远程 URL 中包含您的用户名(类似于 FTP)。

Example without password (SSH):

无密码示例 (SSH):

git remote set-url origin [email protected]/username/repo.git

git remote set-url origin [email protected]/username/repo.git

Example with password (https)

密码示例 (https)

https://name:[email protected]/username/repo.git

https://name:[email protected]/username/repo.git

Source: Git push requires username and password

来源:Git push 需要用户名和密码

Updated 5/14/2018 to correct github.orgto github.comin the original answer

已更新2018年5月14日,以正确的github.org,以github.com原答案

回答by Scott

Check that Windows does not have a pending update. If it does, update and restart.

检查 Windows 是否没有挂起的更新。如果是,请更新并重新启动。

回答by Anthony

This worked for me:

这对我有用:

Deleting the file %localAppData%\GitCredentialManager\tenant.cache and then re-trying your logon.

删除文件 %localAppData%\GitCredentialManager\tenant.cache,然后重新尝试登录。

回答by user2713706

In windows go to credentials manager and check if generic credentials list has the below entries

在 Windows 中转到凭据管理器并检查通用凭据列表是否具有以下条目

git:https://github.com

git: https://github.com

https://github.com

https://github.com

If these entries are not present add these entries with username and password and it should work.

如果这些条目不存在,请使用用户名和密码添加这些条目,它应该可以工作。

回答by Squibly

This happened to me when syncing. Updating visual studio to the latest version did it for me.

我在同步时发生了这种情况。将 Visual Studio 更新到最新版本对我来说做到了。

回答by Tadeá? Bucha

What worked for me was to disconnect from all the existing connections in Visual Studio, remove them one-by-one and connect from scratch. Then immediatelly I was able to clone the repository again.

对我有用的是断开 Visual Studio 中所有现有连接的连接,将它们一一删除并从头开始连接。然后我立即能够再次克隆存储库。

回答by vCillusion

I faced the same issue after I have only TLS1.2 enabled on my PC. After enabling TLS 1.1, SSL.x the issue was resolved. For enabling and disabling I used IISCrypto software. Hope that helps the team and other users.

在我的 PC 上只启用了 TLS1.2 后,我遇到了同样的问题。启用 TLS 1.1、SSL.x 后,问题已解决。为了启用和禁用,我使用了 IISCrypto 软件。希望对团队和其他用户有所帮助。

回答by Andi AR

In my case the same issue coming on below scenario:

在我的情况下,同样的问题出现在以下场景中:

We are under corporate network. So we have our own proxy. When we try cloning we cant able to download due to same error.

我们在公司网络下。所以我们有自己的代理。当我们尝试克隆时,由于同样的错误,我们无法下载。

I added proxy url in our git config.

我在我们的 git 配置中添加了代理 url。

[http]
 proxy=http://YourNameHere:[email protected]:6050/
 sslVerify = false

[https] 
proxy=http://YourNameHere:[email protected]:6050/
 sslVerify = false

Issue disappears and i can do all git operations.

问题消失了,我可以执行所有 git 操作。

回答by Palash Roy

Using Windows Credential manager

使用 Windows 凭据管理器

**Windows Credential manager**

**Windows 凭据管理器**

After seeting username, password in Windows Credential Manager, set git config to read from credential manager. Open gitbash, run command:
git config --global --add credential.helper manager

在 Windows Credential Manager 中设置用户名、密码后,将 git config 设置为从凭证管理器读取。打开gitbash,运行命令:
git config --global --add credential.helper manager