我开始使用Visual Studio Code,我试图将我的测试项目保存到GitHub,但Visual Studio Code总是要求我的GitHub凭据。

我已经在我的PC上安装了GitHub Desktop和Git。我已经跑了:

 git config --global credential.helper wincred

但是Visual Studio Code仍然在要求凭证。

我该如何解决这个问题?

下面是我的.gitconfig文件,位于用户配置文件文件夹中:

    [filter "lfs"]
    clean = git-lfs clean %f
    smudge = git-lfs smudge %f
    required = true
[user]
    name = ddieppa
[user]
    email = fake@live.com
[credential]
    helper = wincred

下面是弹出窗口要求凭据:

我在弹出窗口中输入了我的GitHub凭证,但仍然在Visual Studio Code中的Git输出窗口中得到这个错误:

remote: Anonymous access to ddieppa/LineOfBizApp.git denied.
fatal: Authentication failed for 'https://github.com/ddieppa/LineOfBizApp.git/'

当前回答

除了添加上面的SSH配置项之外

如果窗户

Set-Service ssh-agent -StartupType Automatic

在PowerShell。

现在Visual Studio代码应该不会提示…

其他回答

您可以参考此链接来设置Git凭据。

您可以运行以下命令来保存Git凭据。你不需要每次运行Git命令时都输入用户名和密码(适用于Windows):

git config --global credential.helper wincred

对于Mac / Linux,如何保存Git凭据,请参见Mac和Linux的Git凭据管理器。

Windows 10操作系统:进入控制面板→凭证管理器→Windows凭证→点击Git链接→编辑→更新新密码。这应该有用。

请按照以下步骤进行处理。

卸载Visual Studio Code和Git软件,然后重新安装。将Git存储库克隆URL从SSH更改为HTTPS。

一般来说,您可以使用内置的凭据存储设施:

Git配置——全局凭据。辅助存储

或者,如果你在Windows上,你可以使用他们的证书系统:

Git配置——全局凭据。辅助wincred

或者,如果你在macOS上,你可以使用他们的凭据系统:

Git配置——全局凭据。辅助osxkeychain

第一种解决方案在大多数情况下是最优的。

自动Git认证。v1.45版本说明:

GitHub authentication for GitHub Repositories VS Code now has automatic GitHub authentication against GitHub repositories. You can now clone, pull, push to and from public and private repositories without configuring any credential manager in your system. Even Git commands invoked in the Integrated Terminal, for example git push, are now automatically authenticated against your GitHub account. You can disable GitHub authentication with the git.githubAuthentication setting. You can also disable the terminal authentication integration with the git.terminalAuthentication setting.