pushing with wrong github account from visual studio 2026 #212516
🏷️ Discussion TypeQuestion Bodyi have 2 github accounts, and whenever i push in visual studio 2026, it brings up a pop-up for me to choose an account. i choose the one i want, and then it pushes. i go to github, or look in the code in vs, or whatever, and it never actually says the account i picked. it always says i pushed with the other account. all answers i've found on the internet tell me to, in some way, remove the other account entirely from my computer, but i do actually need both. one of them is this account, and the other is a school account for school projects and stuff. i wanna keep that stuff separated, so i don't want to just remove this account. how do i fix this? |
Replies: 3 comments 1 reply
|
Hey! I totally get how frustrating that is. You want to post or push your school stuff under your school account, but Visual Studio stubbornly keeps routing it to your personal one, no matter how many times you pick the right account in that pop-up window. The reason this happens is that Visual Studio's account switcher is just a UI layer—behind the scenes, Git is looking at Windows Credential Manager and your local repository settings, which are silently overriding whatever you select. Here is the most reliable way to fix it without having to delete either of your accounts:
Once you do that, Git will stop guessing and will always use the correct account for that specific project, while leaving your personal projects untouched! |
|
The 1. Make sure local and CI use the same npm version npm -vnpm 6 ignored peer dependency conflicts, and npm 7 and later treat them as errors. If you run a newer npm locally than your CI image does (or the other way round), the same lockfile can pass in one place and fail in the other. Make CI match your local version, either by setting the same Node version in your CI setup step or by adding 2. Find where the setting comes from npm config ls -l | grep -i peerIt can be set in your user 3. Reproduce the CI failure locally npm ci
4. Read the ERESOLVE message The error has three parts that name the conflict:
Then ask why each version is in your tree: npm explain <package-name>
npm ls <package-name>5. Fix it at the source
rm -rf node_modules package-lock.json
npm install
npm ciCommit the new lockfile once |
|
The account you pick in that popup is only what Git logs in with for the push. The name GitHub shows on a commit comes from the email stored inside the commit, and that comes from your Git config, not from the account you push with. So you're most likely authenticating as the school account and pushing commits stamped with your personal email, and GitHub links them to the personal account. You can check it inside the school repo: If that shows your personal email, that's the whole problem, and you don't need to remove anything from Credential Manager or Visual Studio. Set it per repo so your own projects stay as they are. In Visual Studio go to Git > Settings, expand Git Repository Config (Git Repository Settings in 2022) and put the school name and email there. Or from a terminal in the school repo: No --global, so it only applies to that repo. The email has to be added and verified on the school account (or use that account's noreply address from Settings > Emails), otherwise GitHub won't link it to anyone. If all your school stuff is under one folder you can make it automatic. Add this to your global config (C:\Users<you>.gitconfig): and create .gitconfig-school next to it with a [user] section for the school account. Every repo under C:/School/ picks it up. Commits you already pushed keep the old email. To fix the last one: For several, |
Hey! I totally get how frustrating that is. You want to post or push your school stuff under your school account, but Visual Studio stubbornly keeps routing it to your personal one, no matter how many times you pick the right account in that pop-up window.
The reason this happens is that Visual Studio's account switcher is just a UI layer—behind the scenes, Git is looking at Windows Credential Manager and your local repository settings, which are silently overriding whatever you select.
Here is the most reliable way to fix it without having to delete either of your accounts:
Clear out the cached GitHub credentials in Windows