SOLVED: SSH Git Push To Different Git Account

Last updated on 24 Sep, 2021

In my machine, I usually push code to my personal Github account. There, the username is jobyjoseph. Today, I created a new account. I was trying to push code to that account using SSH. It was not working because Git for some reasons was detecting jobyjoseph, not the new account. I tried git config value updates. That also did not work.

The error looked like this:

ERROR: Permission to backbenchercode/React-Query-Intro.git denied to jobyjoseph.
fatal: Could not read from remote repository.

Finally, following steps worked. Take terminal. Then clear the SSH key links using:

ssh-add -D

Next attach the ssh key of the new account:

ssh-add ~/.ssh/id_rsa_bb

Thats it. After these steps, I could push my code to the new account.