Scott's Recipes Logo

Using Two Git Accounts and Not Being Able to Commit on the Second One

Last Updated On: 2025-09-01 04:31:51 -0400

I recently transitioned to a TWO GIT ACCOUNT world and I found it problematic.

What I did was:

  1. Create a new git account in a different browser.
  2. Generate a new ssh key for the repos on that account. This was done with this:

    ssh-keygen -t rsa -b 4096

  3. Set the new ssh key on the git account’s settings.
  4. Change the .git/config file on EACH repo to use the new account.

    [core] repositoryformatversion = 0 filemode = true bare = false logallrefupdates = true ignorecase = true precomposeunicode = true sshCommand = ssh -i ~/.ssh/id_rsa4096 -o IdentitiesOnly=yes

  5. And then I did the add / commit process for my changes which worked normally.
  6. The problem was when I tried to push the changes, it persistently used the old account.
  7. A lot of debugging happened and the problem was that I needed to edit my ssh config file and remove the block for my old account:

    mate ~/.ssh/config

  8. Inside that file was this line:

    Host github.com Hostname github.com Port 22 IdentityFile ~/.ssh/id_dsa User fuzzygroup

  9. What I needed to do was comment out that whole block as it was essentially saying “for any interactions with the host github.com, always used this ssh file and this username”.
  10. And you would think that fixed it, right? Nope. A bunch of cursing ensued and what I found was that the magic turned out to be that I needed to restart the OSX ssh agent using this trickery:

    eval “$(ssh-agent -s)”

Thank you to my buddy Nick Janetakis for help sorting this out.