简体   繁体   中英

How do I cache GitHub credentials across multiple repositories in Windows?

I'm using GitHub and have several hundred repositories for microservices. I'm using Git for Windows.

Git properly caches my credential information for a given repository, but all of a sudden I'm getting a bunch of random authentication errors and git is constantly asking me for username/passwords for each of my repos.

I need a way to store my credentials once, and keep git from asking me again - even if I'm in a different repo (same GitHub account, of course).

This became particularly painful when I had to change my GitHub password, and access to all 200+ of my repos broke and each one asked me for a password again.

I see there are tons are articles about about caching Git credentials, and they work for me - but what does NOT work is entering my password once of repo A and having it work for repo BZ.

My expectation is that there's once place I can save/update credentials and have it work for my entire GitHub account.

Maintaining git credentials for each repositories and entering them on each push/pull is the most painful thing.

The best way to avoid this is to use ssh url instead of https for configuring git remote. You will find this in the git clone url section. Switch to ssh as it shows https url by default

Follow below steps to configure

  • Create key pair for your machine with below command: ssh-keygen -t rsa -C "your_email@example.com"

  • Upload your public key to Github

  • In your local machine, you will have to remove the existing https remote configuration and replace it with ssh one. You can use below commands:

git remote remove <REMOTE_NAME> git remote add <SSH_URL>

Now, your machine is configured with your Github account and you wont be prompted for credentials ever.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM