1

I wanted to practice using my git bash but could switch accounts.

When I type git config user.name what should I put here?
And what about git config user.email?

Don't I need to type my password anywhere? That's kinda weird. So the problem is that I can't push changes using my second account, I got this error:

! [remote rejected] master -> master (permission denied)
error: failed to push some refs to 'https://github.com

Have I changed my account or not? I don't understand that.
How can I switch accounts correctly?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250

1 Answers1

0

user.name and user.email have nothing to do with authentication (only with commit authorship: see "Why are my commits linked to the wrong user?")

All you need to do to "switch account" is modify your remote url

 git remote set-url origin https://<secondGitHubAccount>@github.com/<user>/<repo>

That will work as long as secondGitHubAccount is an owner or collaborator of <repo>.

You can use a git credential helper to cache your password (and avoid having to enter it for each Git remote operations). For instance, on Windows, you would use the manager helper (see "How to sign out in Git Bash console in Windows?").

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250