Teague Teague - 1 month ago 5x
Git Question

Does Git Bash determine identify by ssh key?

It's going on day 3 and I have still not been able to resolve the following issue:

I originally created a GitHub account 2 years ago. I believe I generated an SSH key for this account. I believe I had loaded the ssh key to my ssh-agent program and then placed the public key on my GitHub account.

Now I recently created a new GitHub account. I created a repo and then cloned that repo to my PC. After making a couple commits, I attempted to push the changes to the repo. However, it stated that I didn't have permission to that repo stating something along the line of 'Permission denied to repo - oldusername does not have access rights'. So it appeared that Git Bash was referencing my oldusername when attempting to push the changes.

I attempted changing my config information via the 'git config user.name' , etc. etc. However, this didn't seem to fix the problem. I then stumbled across something stating that I need an SSH key. I looked further into this and came to the realization that my current Git Bash was referencing an ssh key associated with my old account. So I deleted this old key on my computer, and I also deleted the key from my old GitHub account.

I then proceeded to generate a new SSH public/private key pair. I loaded (or so I believe) the new private key to the ssh-agent. I then added the public key to my new GitHub account. Note that I also left the 'passphrase' option blank as I didn't understand the immediate purpose of it.

After these changes, I attempted to push the changes I made to the remote repo. However, I again received the error "oldusername doesn't have permission to push changes to the repo".

So it appears that my Git Bash is still referencing my old username. Why is this? Does Git Bash use the ssh-agent's loaded ssh-key to determine your identify? If this were the case though, why would it still be referencing my old GitHub user name? P.s. I'm on Windows 10, Git

Any thoughts?


I think the key here is that you used HTTPS to clone the new repository.

I suspect that your credentials are being cached by the credentials helper. See this:


On windows, if you've used the wincred helper (git config --global credential.helper wincred), then this stores your credentials in the Windows credential store which has a Control Panel interface where you can delete or edit your stored credentials. See this for instance:

enter image description here

With this store, your details are secured by your Windows login and can persist over multiple sessions. This was added in Git for Windows

So either:

  1. Try clearing the credential cache for your https cloned repo using the following and try again:

    git credential-osxkeychain erase host=github.com protocol=https


  1. Edit the credentials using the Windows control panel's Credential Manager.