/ git

Storing multiple Git account in keychain

If you have a personal and a work's Github account, you may experience strange things happening. Like, which account is Github going to use?

Note: Only for Mac users.

If you tried cloning a repo for the first time in CLI, you will be prompted for a username and password.

This will be stored in the keychain and used thereafter.

You may for instance, find yourself unable to push to your work's repo even if you set your credentials locally for the repo.

git --config user.name 'workacct'
git --config user.email 'workemail'

The trick is actually this:

git config credential.username 'workacct'

This will cause the CLI to prompt a password for your work's account and this too will be stored in the keychain.

You should now be able to push to your work's repo!