git login command line-login to github from command line with multiple accounts

DevOps

I opened a new GitHub account to separate my biz vs. personal repository.

Now, I git init my local repo and git add remote origin <the repo 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>/<repo.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 login with multiple sets of credentials or how would I somehow reset the original credentials to force password prompt when pushing?

 

EDIT:

 

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 


If you want to unleash your potential in this competitive field, please visit the DevOps course page for more information, where you can find the DevOps tutorials and DevOps frequently asked interview questions and answers as well.

1
Answers

Replies

The git has a credentials system that can help you with this. The cache mode will save your credentials temporarily for about 15 minutes by default. You can configure your credentials in the cache using the below command.



git config --global credential.helper cache



If you want to increase the timeout, you can set the time in the following way.



git config --global credential.helper "cache --timeout=1800"

 
 

This topic has been locked/unapproved. No replies allowed

Login to participate in this discussion.

Leave a reply

Before proceeding, please check your email for a verification link. If you did not receive the email, click here to request another.
WhatsApp
To Top