更改 VisualStudioTeamExplorer 的 GIT 帐户

当从我们公司的私有服务器克隆一个 Git 存储库时,我遇到了一个非常奇怪的情况。存储库不是匿名的(它需要身份验证) ,但是在克隆时,VS 没有询问任何用户名和密码,而是自动使用老员工的旧身份验证。有没有办法删除保存的用户名和密码,并使 VisualStudio 在克隆时提示它们?

105471 次浏览

Look in the Windows Credential manager and remove/update your credentials there:

enter image description here

I am using VS 2017 and this is how I updated my Password for TFS, using Git repository.

  1. From the Menu: Team -> manage Connection
  2. Click on Manage Connection Link -> Connect to Project

enter image description here

It will then open window to connect to your project, here you can update your password.

In my case just removing credentials from Windows Credential didn't fix it. I first removed all git and azure related accounts from Windows Credential, then removed accounts from VS>Files>Account Settings, and then VS asked me new credentials and connected to the project. But my commits were still made with the old account! Finally I found out that it was the git config:

C:\Users\[USER NAME]\.gitconfig

I deleted the whole user section in that file which looks like this:

[user]
name = [OLD ACCOUNT NAME]
email = [OLD ACCOUNT EMAIL]

On next commit VS asked me git account information and done.

If you want to work with different accounts for different projects on same machine, read this.