0

On my computer I am trying to work with two different git accounts. A default one for work, and a private one for play.

In my user folder (MacOS) the default user is defined.

// .gitconfig
[user]
    name = workUserName
    email = work@email.com

In the project .git folder

// .git 
[user]
    name = privateUserName
    email = private@email.com

But when I'm in the project folder and I try to push I get the following failure message:

remote: Permission to privatUserName/project.git denied to workUserName.
fatal: unable to access 'https://github.com/privateUserName/project.git/': The requested URL returned error: 403

What is happening and how can I solve it?

Ulrich Eckhardt
  • 16,572
  • 3
  • 28
  • 55
Ben Carp
  • 24,214
  • 9
  • 60
  • 72
  • 3
    That name and email address is only used when constructing commits. Authenticating to the remote is a different part of git. – Lasse V. Karlsen Jul 11 '21 at 10:18
  • https://stackoverflow.com/q/3860112/7976758 Found in https://stackoverflow.com/search?q=%5Bgit%5D+multiple+accounts – phd Jul 11 '21 at 10:35

1 Answers1

0

The Git FAQ mentions that user.name should be “your personal name, generally a form using a given name and family name.” It also notes that “[t]his configuration doesn’t have any effect on authenticating to remote services.”

If you want to configure multiple accounts, the FAQ documents how to do that both for HTTPS and for SSH.

bk2204
  • 64,793
  • 6
  • 84
  • 100