How to change git user in Visual Studio Code or even in command line? (Permission denied to user1, The requested URL returned error: 403)

16,158

Deleting github information in Keychain worked as explained here.

Although it doesn't let one use multiple accounts at a time.

Share:
16,158

Related videos on Youtube

Satyajit Das
Author by

Satyajit Das

https://www.youtube.com/c/Tennexas https://tennexas.com/

Updated on June 04, 2022

Comments

  • Satyajit Das
    Satyajit Das almost 2 years

    I am in VS code as a particular git user (say user1) and want to pull & commit changes from one of my other github accounts (user2). After pulling my repository & commiting when I push I get the error of type:

    remote: Permission to user2/repository.git denied to user1.
    fatal: unable to access 'https://github.com/user2/repository.git/': The requested URL returned error: 403
    

    So I assume this error is simply because I am 'logged in' as user1 in VS code. But how exactly can I change myself to user2 to be able to work on this repository?

    I am using Macbook. I have tried many variety of ways e.g. changing to SSH cloning & resetting git config without any luck. There has to be a very simple solution to this problem which should be very basic. I was expecting it will ask me for credentials for the second account but it never did.

    • Matt Runion
      Matt Runion over 5 years
      Have you searched the internet for an answer? A quick Google search lead to this, which would possibly work: stackoverflow.com/questions/28238037/…
    • Satyajit Das
      Satyajit Das over 5 years
      This did not work for me.
    • Matt Runion
      Matt Runion over 5 years
      Then the only option that comes to mind is to use the command line and change users.authenticate, then commit your code.
    • Satyajit Das
      Satyajit Das over 5 years
      Can you elaborate bit more? I couldn't find any tag named users.authenticate.
    • Matt Runion
      Matt Runion over 5 years
      That was a typo on my part, sorry about that. I was saying to use the command line to change users/authenticate -- meaning to use the command line to change your user, or to re-authenticate as another user.