Changing the git user inside Visual Studio Code

2020-02-17 09:34发布

问题:

The user for my git commits has changed, but I am not able to change that inside of Visual Studio Code.

I changed the global settings in git, but when I want to push or sync via Visual Studio Code inside my new repos I get the error that the oldusername has not the permission to push into newrepository. At this point it is not the permission. The change of the username did not work for visual studio code. When I use the terminal I can push. It is also not a solution to allow the olduser to push to the newrepository.

I am on Windows 10. So all other tools are working, but just at Visual Studio Code I was not able to change the user.

Any recomondations are welcome.

回答1:

I resolved this issue by setting an email address in Git:

git config --global user.email "email@example.com"


回答2:

Press Ctrl + Shift + G in Visual Studio Code and go to more and select Show git output. Click Terminal and type git remote -v and verify that the origin branch has latest username in it like:

origin git@github.com:DroidPulkit/Facebook-Chat-Bot.git (fetch)

origin git@github.com:DroidPulkit/Facebook-Chat-Bot.git (push)

Here DroidPulkit is my username.

If the username is not what you wanted it to be then change it with:

git add remote origin git@github.com:newUserName/RepoName.git


回答3:

Generally VSCode uses the github credentials from system's credential manager, it doesn't store anywhere in the settings. As question says Changing the git user inside Visual Studio Code, is not inside rather outside.

Search for or Go to credential manager (Windows control panel) -> Windows Credentials -> Update the GitHub password from the list.



回答4:

There is a conflict between Visual Studio 2015 and Visual Studio Code for the git credentials. When i changed my credentials on VS 2015 VS Code let me push with the correct git ID.



回答5:

I had the same problem as Daniel, setting the commit address and unsetting the credentials helper also worked for me.

git config --global user.email '<git-commit-address>'
git config --global --unset credential.helper


回答6:

I was facing the same issue tried multiple options but didn't work for me. Then i tried this method https://stackoverflow.com/a/39608906 and it perfectly worked for me (Thanks to Venkataramana Madugula). Hope it will help you. Visit the link and follow the steps. You just need to remove the github from the list.



回答7:

From VSCode Commande Palette select :

GitHub Pull Requests : Sign out of GitHub.

Then Sign in with your new credential.