Mike Thomsen
Mike Thomsen

Reputation: 37506

Git keeps using old GitHub credentials

I'm trying to set up multiple account credential management for github using these instructions and ran into a problem... Git continues to use my GitHub credentials even when I set up the user.name and user.email properties in the repo to match the work-related SSH key configuration I set up. No matter what I do, it keeps using my personal GitHub account as I see a request to push to the work repo denied to my personal account.

I've tried these steps to remove any credentials that might have been stored in the macOS keystore. It's behaving like it's completely ignoring the SSH configuration. Any idea how to fix this?

Upvotes: 2

Views: 172

Answers (1)

Geno Chen
Geno Chen

Reputation: 5214

First, user.name and user.email has nothing to do with credential check (though sometimes it will be checked by server for identifying whether these commits are made by you, but not affect your question).

Second, you didn't mentioned about changing remote or changing repository, and the sites you mentioned didn't talk about it, too. So I am guessing what you have met now:

  1. You have a local repository, usually git push it to your personal account.
  2. Now, you want to git push the same repo to your work-related account.
  3. You tried changing user.name, user.email, git credential-helper (on macOS it is git credential-osxkeychain), but those makes nothing, Git keeps warning you that you don't have permission to your personal account.
  4. You asked the current question.

If so, then I guess:

  1. You should grant the permission of your working account to your personal account's repository, or
  2. You should create a new repository in your working account, and git remote add or git remote set-url for pushing it to your working account.

Upvotes: 1

Related Questions