gitgithub

Log in to GitHub from the command line with multiple accounts


I opened a new GitHub account to separate my business vs. personal repositories.

Now, I git init my local repository and git add remote origin <the repository HTTPS URL>

I try to push, and it seems to always take the credentials of my original account, not prompting me for the credentials for the new account.

I tried using the URL format with

https://<username>:<password>@github.com/<username>/<repository.git>

but that doesn't seem to help: I still get an error that the credentials are invalid for the original account username.

How do I log in with multiple sets of credentials or how would I somehow reset the original credentials to force password prompt when pushing?


The only way I managed to push right now is by specifying the username:password@github.com/ in the URL in the git push command.


Solution

  • The only way I managed to push was by specifying the username:password@github.com/ in the URL in the Git push command.