Switch GitHub account on macOS terminal

If you have multiple GitHub accounts and are getting error messages like this while pushing code to the repo

“remote: Permission to svram/twittering.git denied to <currently-configured-username>
fatal: unable to access ‘https://github.com/svram/<reponame>.git/’: The requested URL returned error: 403″

This means that the currently configured username on your terminal is not the one whose repo you are intending to commit code to. The first step to fix this is to list the current configuration like so

git config --list

You will get a result which will inform you about the username and email which is currently configured.


If your github username and email are not consistent then change those first with

git config --global user.name ""
git config --global user.email ""

One of the simple ways to do this on macOS is to delete the password of the existing GitHub account configured from the Keychain.

  • Open the Keychain, click on All Items and then search for git. You can delete the password entry which comes.
  • Once this is done, try to do a git push and it should ask you to reauthenticate. I recommend using the visual studio integration. It makes life really simple while developing code

There are other ways to do this which would work across windows, linux and macOS too. That involves generating an SSH keypair and authenticating your terminal/computer with GitHub. I recommend following this tutorial for the steps.

No comments yet.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Max level reaching...

%d bloggers like this: