

You’ll want to use SSH keys anyway for Git, so credential management should be a non-issue. Managing Credentials for Multiple Accounts This overrides the default config, so even if you change your default account, the local account will still be used for this repository. However, for each repository that uses a different account, you’ll want to leave out the -global flag: git config user.name username

Set your global username and email to your most often used account, as it will be the default for all new repositories and repositories without any configuration. The solution is to set a custom config for each repository that uses a different account. Because it sets it globally, if you want to checkout a project on a different account, you’ll break the settings for your other repositories. This will set the global config to the new username and email. You’ve probably had to run the following commands to change your user account name and email: git config -global user.name username These details are defined in git‘s config. In some cases, if you use the same email for different accounts, the push may go through but show up with a different username in the commits, which may not be ideal. If your username is different than the account you have credentials for, you won’t be able to push or pull until you fix it. The password for the account is asked every time, or stored in the keychain, or irrelevant if you’re using SSH keys (which you should). The only details it uses when doing so are your email and username. When it does this, it uses your Git account details. It only connects to the remote repository when pushing or pulling updates.
#How to use git bash on mac code#
The first thing to understand is that Git is entirely local-your local Git repository isn’t controlled by the server you use to store code on.
