Github user seems to "stick" with old user name and is not using new user as set in settings of PyCharm

Answered
Dear all,
I used to use the Github userid of a collegue, let's say his Github name is "arc". PyCharm worked fine, one could make a project and with a click create a repository, with files, on Github. Now I have my own userid on Github, mzaanen, and I have adjusted the settings in Pycharm accordingly (file, Project settings, Version Control, GitHub). Now, when I create a project in PyCharm and send it to Github, it does make the repository, however, when trying to upload the files:

23:41:56.830: cd E:\djangoprojects_hp_17\test
23:41:56.832: git init
Initialized empty Git repository in E:/djangoprojects_hp_17/test/.git/
23:42:04.054: cd E:\djangoprojects_hp_17\test
23:42:04.055: git add –ignore-errors – jaja.py
23:42:04.152: cd E:\djangoprojects_hp_17\test
23:42:04.153: git commit -m "Initial commit" –
[master (root-commit) e42e12c] Initial commit
1 file changed, 2 insertions(+)
create mode 100644 jaja.py
23:42:04.321: cd E:\djangoprojects_hp_17\test
23:42:04.322: git push –progress origin master –set-upstream

remote: Permission to mzaanen/test.git denied to arc.
fatal: unable to access 'https://github.com/mzaanen/test.git/': The requested URL returned error: 403

It drives me up the wall, somewhere, I don't know where, "arc" is sticking around and I can't get rid of this name. Please assist, this has already cost me many hours...

PyCharm V3.4.1.

Thanks,
Kind regards,
Maarten
0
5 comments

For anyone who still stumbles upon this issue, you can fix it by revoking GitHub personal access token for your JetBrains product. You may find them in GitHub->Settings->Developer Settings -> Personal Access Tokens. I revoked all my tokens for both old and new account just in case. Then, on you next push attempt, a GitHub login window will pop up, where you login with your new account.

Also, if you are using macOS, you should try deleting your github credentials in osxkeychain. This can be done by simply going to keychain access app, searching github and deleting the ones with Intelij in name

Hope this helps someone.

5

> Also, if you are using macOS, you should try deleting your github credentials in osxkeychain

This is the solution, not revoking tokens. When pushing from the command line, no tokens from IntelliJ is used, as they are securely stored in the IntelliJ password safe and are not available for external processes

And the explanation is that git by default has its own credential helper installed, that saves credentials to the keychain. And if wrong credentials are there, git keeps using them without asking IDE or user for input.

1

Another thing that could cause the issue is git global configuration. You might have used the following command after initiating your git repository. 

$ git config --global user.email <old-username@example.com>

To fix the issue change user.mail of each repository to your JetBrain username, which is an email address. 

$ git config user.email <current-username@example.com>

 If you only have one Github  account, then you can add the --global option. 

$ git config --global user.email <current-username@example.com>

7

Dtahmasb  Definitely worked, the issue seems to be in the global git config, thank you.

0

For me it was also necessary to delete the access tokens from one account in order to prompt PyCharm into requesting me which account I wanted to use. The settings were in in the Applications part under the Integrations heading, then I removed authorization both from “Authorized GitHub Apps” and “Authorized OAuth Apps”. I think it was the latter that did the trick, but I am not sure.

In my particular case it was to get the CoPilot plugin to use my company's enterprise account (with licensed CoPilot) instead of my “personal” account. Thanks for the help.

0

Please sign in to leave a comment.