在 VScode 中更改 git 帐户



我想更改VSCode中使用的git帐户。我创建了一个新帐户,不想再使用旧帐户

到目前为止我尝试过的:-

  1. 这个堆栈溢出问题中的所有内容都改变了VSCode中的Git帐户
  2. 在这个 VScode 上的 Chang git 帐户中
  3. 我还取消了VSCode设置中的GitHub Authentication
  4. 阅读有关GitHub集成的VSCode文档,但他们没有提到这些事情

但我似乎无法让它工作

这是我在推送提交时遇到的错误

git push -u origin master
remote: Permission to username1/todo-app.git denied to username2.
fatal: unable to access 'https://github.com/username1/todo-app.git/': The requested URL returned error: 403

我该怎么做才能解决这个问题?

提前致谢

首先,不要按照第一个链接中的建议使用wincred:使用manager-core(与 Git for Windows 打包的 Git 凭据管理器(。

git config --global credential.helper manager-core

其次,确保适用于 Windows 的 Git 是最新的(2022 年第 2 季度为 2.35.1.windows.2(

第三,从凭据管理器中清除旧 URL

printf "protocol=httpsnhost=github.com" | git credential-manager-core erase

注意:git-credential-manager-core.exe位于C:Program FilesGit mingw64libexecgit-core文件夹中:确保这是%PATH%的一部分 .
同样适用于printf.exe:在C:Program FilesGitusrbin中。

最后,尝试并推送:这应该会触发一个弹出窗口,要求您输入 GitHub 凭据:输入新的凭据。

请记住:密码必须是 PAT(个人访问令牌(,自 2021 年 8 月起是强制性的。

最新更新