Reputation: 6875
I have set my global github user settings in my computer.
I have second github account with a different name "myusername2". I cloned a repository from "myusername2" account to my computer. But global user settings are "myusername". So I set the username and email using command:
git config user.name "myusername2"
git config user.email"myemail2"
But when I push commits, the authentication error occured. I think this is for password not authenticated. So how can I solve this problem?
Upvotes: 2
Views: 1210
Reputation: 1329092
If an authentication error occurs when pushing with an HTTPS URL, this is because the cached credentials stored by the credential helper (check what git config credential.helper
returns) are wrong.
To force said credential helper to select the right account, I would add the username in the HTTPS url:
cd /path/to/local/repo
git remote set-url origin https://[email protected]/<username2>/repo
Upvotes: 4