4

I have 2 github account X (professional one) and Y (personal one).

On my personal computed, I used both account, with Visual Code.

But now, when I try to push some changes to my repository, I have a message :

Permission to Y/repo.git denied to X.


It's a duplicate of this, but the answer there are not working for me.

I tried :

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

Didn't work. I tried without --global, didn't work.

I also saw this answer, but I have no idea how to 'un-blacklist' a file. Anyway I can't even find my .gitconfig.


I'm loosing patience and hope, if anyone has a solution to this, I will be very grateful for sharing !

lurker
  • 56,987
  • 9
  • 69
  • 103
Astariul
  • 2,190
  • 4
  • 24
  • 41

3 Answers3

5

I had a similar problem. @Astariul's comment worked for me. I'll post it here for visibility. He linked to https://stackoverflow.com/a/40907049/9494790

Basically, an old Git login is being stored in Windows and needs to be deleted. Go to Control Panel -> User Accounts -> Manage your credentials, delete all the ones involving Git and VS Code, then restart VS Code.

RedDragonWebDesign
  • 1,797
  • 2
  • 18
  • 24
2

I fixed the issue on my machine by signing out of the account I was logged into on vs-code by using the Accounts button on the left side bar. I had to go through the login process again with the trusted account.

enter image description here

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
MAJ
  • 21
  • 1
2

I just wanted to add to this for future reference.

I was experiencing the same issue. However, that was because I added the remote using the SSH git@ style URL instead of the https:// URL. That made my computer try to authenticate using my SSH keys instead of my login credentials.

Since I didn't have the SSH keys on my machine, it would never work. Once I removed and re-add the remote using git remote add origin https://github.com/<link-to-my-repo> then it prompted me to login on my browser to authenticate, and everything worked as expected!

Hope this helps someone else in the future!