Repeated prompts to enter your Git username and password are a frustrating annoyance developers can live without.
Unfortunately, if your Git installation has not been configured to use a credential store, you encounter repeated authentication prompts on fetches and pulls.
Fortunately, it's a problem that is easily solved.
How to set a Git config username and password
To permanently set Git username and password fields, issue the following command in the terminal window for Git to use a credential store:
git config --global credential.helper store
If all things go right, the next time you perform a fetch or pull from a remote repository, you are prompted for your Git username and password. Provide those, and they are stored permanently in a file named .gitcredentials in your account's home directory. In all future interactions, your credentials are passed to any remote Git repositories with which you communicate.
Git credentials fail authentication
If you are trying to authenticate against an online Git hosting service, such as GitHub, GitLab or Bitbucket, and your authentication attempts fail, make sure you provide an access token as the password.
Push, pull and fetch operations with GitHub and GitLab are not allowed using the account password. You must use an access token for the Git password.
Git Credential Manager conflicts
If you are not prompted for a username and password after this Git config change, the likely cause is a conflict with Git Credential Manager (GCM).
GCM is an alternate way for Git to perform OAuth-based authentication. After a successful authentication, GCM stores your Git username and password in Windows Credential Manager. If GCM is pre-configured, it may conflict with Git's credentials store.
If you suspect a conflict with GCM, check the gitconfig file in the Git installation's \etc directory and the .gitconfig file in the user's home directory. Look for any entries under the [credential] heading that set the helper to anything other than store.
If additional or alternate [credential] entries exist in any Git configuration file, delete them. As due diligence, back up your Git config file before changing anything.
The next push or pull to your remote server then prompts you for your Git username and password, and your credentials are permanently stored.
You don't have to provide your Git username or password ever again.
Cameron McKenzie has been a Java EE software engineer for 20 years. His current specialties include Agile development, DevOps and container-based technologies, such as Docker, Swarm and Kubernetes.