Back

Blog

Fix GitHub Wrong Account Push

What to do when git push says Permission denied because VS Code is signed in as someone else.

This happens a lot on shared computers. One person signs into GitHub in VS Code. The next person opens the same PC, tries to push their own repo, and gets a 403 error.

The error usually looks like this: Permission to username/repo.git denied to someone-else. That means Git is using the wrong saved login. Your remote can be correct, but Windows still remembers the previous GitHub account.

Also check VS Code: click the account icon at the bottom left, sign out of the wrong GitHub account, then sign in with yours before you push again.

Check your remotes

Confirm the project is pointing at the right GitHub repo. You should see origin with your repo URL. Do not try to remove the other person's username as a remote. That name is an account, not a remote.

git remote -v

Clear the saved GitHub login (easiest way)

1. Open Windows Credential Manager: Start, search Credential Manager, then open it. 2. Click Windows Credentials. 3. Find anything like git:https://github.com or github.com. 4. Remove those entries. After that, run git push and sign in with your own GitHub account.

git push

See saved GitHub logins in the terminal

If you prefer the terminal, this lists Windows credentials that mention git. Use it to confirm the old login is there before you delete it.

cmdkey /list | findstr git

Also search for github entries

Run this too in case the saved login uses github in the name instead of git.

cmdkey /list | findstr github

Delete the old GitHub login in the terminal

Removes the saved GitHub HTTPS login from Windows. After this, the next push should ask you to sign in again. If the name is slightly different, copy the exact Target from cmdkey /list.

cmdkey /delete:git:https://github.com

Push again and sign in correctly

Try uploading again. When the browser or VS Code login appears, sign in with YOUR GitHub account, the one that owns the repo or has write access.

git push

First-time push for a new branch

If Git says your branch has no upstream yet, use this once. Replace main with your branch name if needed.

git push -u origin main

Check who GitHub CLI is using (optional)

If you use GitHub CLI (gh), this shows which account is active. If it is the wrong person, sign out and sign back in as yourself.

gh auth status

Sign out of GitHub CLI (optional)

Clears the GitHub CLI login so you can sign in as the correct account.

gh auth logout

Sign in with GitHub CLI (optional)

Opens the login flow. Choose HTTPS and sign in with the account that owns your repo.

gh auth login