我开始使用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/'

当前回答

自动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.

其他回答

下面的步骤教你如何:

生成SSH密钥(不含密码短语**) 将第1步中生成的公钥添加到Git存储库中 确认以上步骤已成功完成 第一次提交(无需提供用户名/密码)

**如果您的工作特别敏感,生成没有密码短语的SSH密钥是不明智的。

OS - Fedora 28 |编辑器- Visual Studio Code v1.23.0 | Repository - Git

生成SSH密钥:

ssh -t rsa -C "email@goeshere.com" 输入保存密钥的文件:按“Enter” Enter passphrase:按“Enter” 再次输入相同的密码短语:Press Enter

完成上述步骤后,您的公钥的位置将显示在终端窗口中。如果当前登录的用户是'bob',那么公钥的位置将是/home/bob/.ssh/id_rsa.pub

复制并导入公钥到GitHub:

猫/home/bob/.ssh/id_rsa.pub 将现在显示在终端窗口中的整个公钥复制到剪贴板 登录https://github.com并登录 单击界面右上角的用户图标,选择“设置” 单击“SSH”和“GPG”键 单击“新建SSH密钥” 输入标题,将复制到剪贴板的公钥粘贴在第一个项目符号中,单击“添加SSH密钥”

确认以上步骤:

ssh -T git@github.com 是的 嗨!您已成功验证,但GitHub不提供shell访问。

第一次提交/推送无需输入用户名/密码:

触摸用法 Git添加test.txt Git提交-打开编辑器,输入消息并保存文件。如果你的编辑器是vi,打开文件后按I,输入消息,按Esc,然后输入:x保存修改。 git推

您可能遇到的唯一问题是当您尝试SSH到GitHub时。这个链接将提供一些帮助-

错误:代理程序承认签名失败

寻找快乐!

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

如果窗户

Set-Service ssh-agent -StartupType Automatic

在PowerShell。

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

我们需要配置VS Code以在Git命令之上提供身份验证。

下面我将展示如何设置扩展设置。

我设法通过执行以下步骤来阻止这种情况。

卸载GitHub Desktop(我不确定这是必要的) 卸载凭证管理器:cd“C:\Program Files\Git\mingw64\libexec\ Git -core”,然后执行Git - Credentials - Manager .exe卸载 重置凭证帮助使用wincred: git config——global credential。辅助wincred 使用Visual Studio Code来推动一些更改并重新输入凭证。

注意:我使用个人访问令牌作为密码。

这对我很有用。你只需要输入一次PAT。 Git配置——全局凭据。辅助wincred