'Switching git users

According to this SO question (here) and many others, you can change the user you are working with by simply

git config user.name "username1"
git config user.password "password1"

Ok. Great that's done, and when I check with

git config user.name //I get username1

But as soon as I push to my git repo that I created in the account using that username, I get...

remote: Permission to username1/reponame.git denied to username2

I should mention, when I type

ssh -T [email protected]

I get

Hi username2! You've successfully authenticated, but GitHub does not provide shell access.

So, ssh authentication takes over any other way of signing into git? How can I maintain that ssh authentication with username2 for the username2/repo.git (work github account), while still being able to switch to username1/repo.git (personal github account)?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source