'Changing the Git user inside Visual Studio Code
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 repositories 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.
How can I fix this problem?
Solution 1:[1]
I resolved this issue by setting an email address in Git:
git config --global user.email "[email protected]"
Solution 2:[2]
Generally, Visual Studio Code uses the GitHub credentials from the system's credential manager. It doesn't store it 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.
Solution 3:[3]
You can view all of your settings and where they are coming from using:
git config --list --show-origin
Delete the unwanted credentials from the directory and then Visual Studio Code will ask you for the credentials next time when you perform Git operation.
Solution 4:[4]
1. Sign out of your current account (only if you want to switch the current account)
2. Change Git settings globally
git config --global user.email [email protected]
git config --global user.name YushaBinArif3
After completing the above steps, close and reopen Visual Studio Code. The next time you will execute your Git commands, you will be asked to login via browser, make sure you open that link in a browser where your desired GitHub account is logged in.
Solution 5:[5]
To check/get old values:
git config --global user.email
git config --global user.name
Output:
[email protected]
youroldgoodname
To set new values
git config --global user.email [email protected]
git config --global user.name yournewgoodname
Solution 6:[6]
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 [email protected]:DroidPulkit/Facebook-Chat-Bot.git (fetch)
origin [email protected]: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 [email protected]:newUserName/RepoName.git
Solution 7:[7]
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
Solution 8:[8]
This could be because of the reason that the credentials are saved and you need to update those credentials and you can do that by following the below steps:
Control panel ? Credential Manager ? under Generic credential, you will be able to see the credentials related to Git.
Try to update them. If that does not work, delete them and add new ones.
For other platforms or different versions of the operating system, you need to find out where the credentials are saved related to Git and update them.
Solution 9:[9]
There is a conflict between Visual Studio 2015 and Visual Studio Code for the Git credentials. When I changed my credentials on Visual Studio 2015, Visual Studio Code let me push with the correct Git ID.
Solution 10:[10]
I just signed up for a new GitHub account to create a project and I had the same issue. I resolved it by doing the following:
$ git credential-osxkeychain erase
host=github.com
protocol=https
> [Press Return]
When I attempted to push to my new remote repo after this, it asked me to sign in to the new account; I did that, and it worked.
Solution 11:[11]
Git Graph
You can change the git user in the Extension Git Graph
easily.
- Go to the
Extensions
tab and installGit Graph
. - Go to the
Source Control
tab in theSOURCE CONTROL
accordion menu. - Click on the
View Git Graph (git log)
icon. - Click on the
Repository Settings
icon. - In the
User Details
section, clickEdit
and change the Git User Name and Email.
.git/config
A simpler solution that works with any IDE is to add the user to the .git/config
file:
[user]
name = bar
email = [email protected]
Solution 12:[12]
From the Visual Studio Code Command Palette, select:
GitHub Pull Requests: Sign out of GitHub.
Then sign in with your new credentials.
Solution 13:[13]
Firstly set VS code to default editor through git like
- git config --global core.editor "code --wait"
- git config --global -e
After setting vs code to default editor , then type
- git config --global --list
it will show you all global configuration .
If you want to change any just type
-> git config --global -e
Vs code will open then change your user.name , email-address & any thing you set in easy manner.
Hope i solve your problem.
Solution 14:[14]
The quick and easy way is to sign in at https://github.com as the user you want to use, then in the lower left corner, sign-in to Github (sign off if any user is currently connected). VS Code will use the user that you are already logged in as in the browser.
Solution 15:[15]
From within the Visual Studio Code terminal,
git remote set-url origin https://<your github username>:<your password>@github.com/<your github username>/<your github repository name>.git
for the quickest, but not so encouraged way.
Solution 16:[16]
I was running into this because I had incorrectly typed my GitHub/GitLab credentials into the pop-up from Windows Credentials Manager. In Windows 10, access Credential Manager from Control Panel; you can also just search for Credential Manager in the search bar. In Credential Manager, find your Git credentials in Windows Credentials and amend to the correct version. After this, Git worked from the CLI.
Others have made suggestions about trying to trigger the pop-up again by signing out of GitHub and running git pull
from the CLI, but neither of those worked for me.
Solution 17:[17]
I tried several changes to settings, including the Windows Credential manager. In the end, I:
- Closed Visual Studio Code
- Opened PowerShell
- Set the credentials there, with the --global option
- Closed PowerShell
- Opened Visual Studio Code
Visual Studio Code is now happy with its Git name and email, and I'm able to push and pull!
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow