What is the process of saving username and password in Git?

240    Asked by Dhruvtiwari in Salesforce , Asked on Sep 19, 2023

 I have been trying to use Git for a few days. But I cannot understand the process of saving username and password on the platform. Can I get any help regarding that? 

Answered by Elayne Balding

Saving username and Git config password may seem difficult. But we suggest you run the command:

$ git config credential.helper store

The next step is to pull. So, follow the next command:

$ git pull

Once that is done, you can provide the username and password, and remember both of them as these two will be required later.

After providing the username and password the system will store both of them in a text file present at ~/.git-credentials.









Your Answer

Answer (1)


In Git, you can save your username and password by using the credential caching or credential store mechanism. To enable credential caching, you can use the "git config" command to set the "credential.helper" configuration to "cache" with a specified timeout, like "git config --global credential.helper 'cache --timeout=3600'". This will cache your credentials for the specified time, allowing you to avoid entering them repeatedly.

Alternatively, you can use the credential store by setting "git config --global credential.helper store". This method stores credentials in a plaintext file, which might be less secure, so use it with caution. After configuring either option, Git will prompt you for your credentials the first time, and subsequently, it will use the cached or stored credentials automatically.

6 Months

Interviews

Parent Categories