我开始使用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远程URL从HTTPS更改为SSH:

git remote set-url origin git@github.com:username/repo-name-here.git

其他回答

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

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

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

git config --get remote.origin.url

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

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

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

我在Visual Studio Code中遇到了类似的问题。

我通过将远程URL更改为https(在文件.git/config中)解决了这个问题:

[remote "origin"]
    url = https://user@server.com/plesk-git/project.git

还有:

git config --global credential.helper wincred

我又拉了一次,弹出了Windows凭据,问题解决了。

打开Visual Studio Code的用户必须与执行Git命令的用户相同。然后在终端中执行如下命令。

git config --global credential.helper store
git pull

在下一个操作push或pull中,您将不会看到它请求Git凭据。