-1

I've tried many methods to push to my repo, but I keep getting this error:

> git push
remote: Permission to <ACCOUNT_2>/<REPO>.git denied to <ACCOUNT_1>.
fatal: unable to access 'https://github.com/<ACCOUNT_2>/<REPO>.git/': The requested URL returned error: 403

I'm using VS Code to push changes to a repo owned by <ACCOUNT_2> with <ACCOUNT_2>'s git config name and email.

The error always happens. Is there a way to switch accounts?

I had the same problem before with the opposite accounts, and the solution was to change the git config name and email, and then redownload VS Code.

I expected to be able to push my changes normally, but it's strange that switching to different accounts in Git is so complex. I'm planning on switching accounts many times in the future, so is there a better solution?

Git Output:

2023-08-11 18:21:50.006 [info] > git log --oneline --cherry main...main@{upstream} -- [45ms]
2023-08-11 18:21:50.712 [info] > git pull --tags origin main [702ms]
2023-08-11 18:21:50.712 [info] From https://github.com/<ACCOUNT_2>/<REPO>
 * branch            main       -> FETCH_HEAD
2023-08-11 18:21:51.674 [info] > git push origin main:main [959ms]
2023-08-11 18:21:51.674 [info] remote: Permission to <ACCOUNT_2>/<REPO>.git denied to <ACCOUNT_1>.
fatal: unable to access 'https://github.com/<ACCOUNT_2>/<REPO>.git/': The requested URL returned error: 403
M7ilan
  • 1
  • What kind of machine (operating system) are you on? – matt Aug 11 '23 at 16:10
  • 1
    "it's strange that switching to different accounts in Git is so complex" There are no "accounts" in Git. Git does not do authentication. What you are switching is accounts in GitHub — and yes, that's complex. That notion that you are trying to access this repo via `https` is already a Bad Smell; you should be using SSH for GitHub authentication. Things do get a lot simpler once you've done that, it's just a matter of setting your SSH up correctly and using the correct site name in the remote specification. – matt Aug 11 '23 at 16:12
  • 1
    The `user.name` and `user.email` parameters in Git are only for Git to attribute commits to their authors. They have *absolutely nothing* to do with any sort of authentication. – Jim Redmond Aug 11 '23 at 17:11

1 Answers1

0

Control Panel ->User Accounts -> Credential Manager

Select the Windows Credentials tab

Find your credentials for ACCOUNT1 under Generic Credentials - then delete that entry.

M S
  • 137
  • 8