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

当前回答

我在Visual Studio Code和Ubuntu 20.04 (Focal Fossa)上运行:

它自动解决了定期询问凭证的问题:

git config --global credential.helper store

其他回答

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

如果窗户

Set-Service ssh-agent -StartupType Automatic

在PowerShell。

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

下面这篇文章:

您可以将GIT_SSH环境变量设置为PuTTY的plink.exe程序。

(然后使用pageant.exe程序作为身份验证代理。)

如果你是在Windows电脑上,那么安装Git for Windows。就是这样!

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

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

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

你应该能够像这样设置你的凭证:

git remote set-url origin https://<USERNAME>:<PASSWORD>@bitbucket.org/path/to/repo.git

你可以像这样获取远程URL:

git config --get remote.origin.url