How to fix Git always asking for credentials when connecting to remotes

How to fix Git always asking for credentials when connecting to remotes

It can be somewhat tiring when you have to enter your username and password every time you are connecting/transferring data from your local repository to the remote repository with your personal computer. However, if you use SSH transport for connecting to remotes you might not encounter this "problem". (Since you should have a key without a passphrase which allows you to securely transfer data without typing in your credentials).

The case isn't the same if you are using HTTP protocols as you are required to enter your password and username for every connection. Luckily, Git credentials system can help you with this.

Using the steps below, you can store your Git credentials without any hassle.

Firstly, if you haven't already configured your git bash, run the following in your git command prompt environment to set up your username and email address:

git config --global user.name "your username"
git config --global user.email "your email address"

To confirm if what you have inputted is accurate, run the following:

git config --global user.name
git config --global user.email

To store your credentials, run the following in your git bash. (This ensures that you don't get asked for it every time you are trying to make a connection with your remote repository from your personal computer).

git config --global credential.helper wincred

This uses your Windows Credential Manager to store your credentials in the disk, (where it will never expire hence you don't need to type in your email/username and password whenever you are connecting with your remote repository unless you change your password for the Git host).

With this, you will be saving yourself the stress and time in inputting your credentials anytime you are making a push to your GitHub repository.