3

I want to change the original user that I initialized on Visual Studio Code for my GitHub account. I created a different account for work versus my personal one and cannot change the personal account to the work account.

I am trying to send the changes to GitHub but keep running into a permission denied to my personal account.

Git: remote: Permission to Organization/Repository.git denied to *personal account*

github push

I know the GitHub push to my personal account works. So I know git and GitHub was setup properly. However, even after deleting git and Visual Studio Code, I cannot get the original sign in prompt to GitHub or find a way to change the user.

edit*

$ git push -u origin master
remote: Permission to Organization/TestRepo.git denied to mebrunner24.
fatal: unable to access 'https://github.com/Organization/TestRepo.git/': 
The requested URL returned error: 403

This is the error that I get when I try to use git bash as well. Essentially the same as VSC. This is not the same error as putting mutliple accounts. I cannot change the account period.

At this point I'm looking to completely wipe out git on this computer and start fresh. However, when I uninstall git I'm STILL having the same issue.

*Edit 2: I have now added myself to the organization as mebrunner24 and I still cannot get past this error. I am at a complete loss. I can push everything to my personal repository on this machine just fine. But going to the Organization one does not work at all

*Edit 3: I have added myself to the organization and provided myself write access for repository I want to write to. This works, kind of. It shows up as the work account, not my personal account that gave the commit. Once I remove myself from the Organization, I'm still having this same issue

mebrunner24
  • 65
  • 1
  • 2
  • 7
  • Is this private repository of organization are you trying to access? – Nisarg Jun 14 '18 at 14:01
  • No, at the moment it's public. But will be private soon – mebrunner24 Jun 14 '18 at 14:07
  • Possible duplicate of [How can I have multiple git accounts on a single development machine?](https://stackoverflow.com/questions/50354412/how-can-i-have-multiple-git-accounts-on-a-single-development-machine) – vanogrid Jun 14 '18 at 14:53
  • @vanogrid - i got the same error when i try to run the "git push origin HEAD" command in the .git folder in git bash – mebrunner24 Jun 14 '18 at 15:11
  • 1
    See https://stackoverflow.com/q/3860112/1256452 - skip down to answers about using https, if you prefer using https to ssh. Note that Git itself generally does not do authentication, it leaves that to helpers (ssh itself when using ssh, or "credential helpers" which vary per OS when using https). – torek Jun 15 '18 at 00:15
  • @torek unfortunately that does not work either. that was the original setup I tried – mebrunner24 Jun 15 '18 at 15:09

3 Answers3

3

Try this:

  1. In your terminal, navigate to the repo you want to make the changes in.
  2. Execute git config --list to check current username & email in your local repo.
  3. Change username & email as desired. Make it a global change or specific to the local repo:

    git config [--global] user.name "Full Name"

    git config [--global] user.email "email@address.com"

  4. Per repo basis you could also edit .git/config manually instead.

Nisarg
  • 1,631
  • 6
  • 19
  • 31
  • 1
    I can change the user.name to the username I'm wanting to - not mebrunner24. However, when I change it to the user that I want the repository to go to, I still have the same error – mebrunner24 Jun 14 '18 at 15:03
  • Do this to fix your repo: This is example. `git remote set-url origin git@github.com:username/Organization/TestRepo.git` clone your repos using ssh and not https, and they’ll always be writable. You can get the ssh url from the green “clone or download” button. – Nisarg Jun 14 '18 at 15:11
  • 1
    that also did not work. I got it to kind of work when i added myself to the organization and gave myself write access. When I remove my personal account, i still run into the same issue though – mebrunner24 Jun 14 '18 at 16:03
3

Go to control panel ,select user accounts options ,credential manager,edit generic credential for existing GitHub account and remove the existing account

1

Your issue isn't with git or VS Code. Each individual local repo has a git configuration. So if you go to a new directory and type in git init you can change anything you may need.

This is more info on it here: https://git-scm.com/docs/git-config

You can see these files if you show hidden files in your directory. The folder is labeled .git and that's where you need to be.

Dylan Wright
  • 1,118
  • 12
  • 19
  • that still doesn't solve my problem. I tried to initialize another folder and send it to a new repository but I'm still being denied because I'm logged in as my personal username that is on GitHub – mebrunner24 Jun 14 '18 at 13:37
  • https://help.github.com/articles/setting-your-username-in-git/ You have to manually change this in your configuration. – Dylan Wright Jun 14 '18 at 13:41
  • $ git push -u origin master remote: Permission to Oganization/TestRepo.git denied to mebrunner24. fatal: unable to access 'https://github.com/Organization/TestRepo.git/': The requested URL returned error: 403 I want to change the "mebrunner24" to a different username. I've set the username using the link you provided to the intended username but that still does not work – mebrunner24 Jun 14 '18 at 13:43
  • So saying Organization makes me believe that this is a private repo. Reading some of your comments below I saw that you added your name to this account and got write access. You might need to figure out why that is, and the answer therefore resolving your issue. Here is another link https://stackoverflow.com/questions/3860112/multiple-github-accounts-on-the-same-computer this should help more. – Dylan Wright Jun 15 '18 at 17:39