-1

I need help with using different passwords for multiple local projects on my machine. I initially had set the global name and email as below

git config --global user.name userA
git config --global user.email userA@email.com

and a local name and email as below

git config --local user.name userB
git config --local user.email userB@email.co.za

This is all good but then when I need to push using the local settings I can't, I get the erorr below

remote: Permission to userB/some-project.git denied to userA.
fatal: unable to access 'https://github.com/userB/some-project.git/': The requested URL returned 
error: 403

Although the user in the new folder is set differently with the local user and I verified the name and email are changed for the local setup. Git somehow still points to the global setting. I have tried a few edits as suggested here, but it still uses the login settings for the global user.

Wylie
  • 350
  • 3
  • 12
  • `user.name` and `user.email` are not used for authentication during `git push`, because they require no proof of validity: you can set your `user.name` to Dracula or Frankenstein and Git will believe you. When you push to GitHub, you choose whether to use https or ssh (via the URL you use to reach GitHub). When you use https, your Git software uses a *credential helper* to obtain user name and password (token, really) to send to GitHub. When you use ssh, your Git software runs ssh, which does its own thing. – torek Jun 16 '22 at 09:32

1 Answers1

0

Are you using RSA authentication? If so, you are most likely authenticating as your user, userA. userB needs to add userA as a collaborator to their git project. https://docs.github.com/en/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-access-to-your-personal-repositories/inviting-collaborators-to-a-personal-repository

Danimal
  • 68
  • 3