How to Configure Git Credentials to Recall Password and Username

John Wachira Feb 02, 2024
  1. Configure Git to Store Your Password
  2. Use credential.helper to Store Your Password
  3. Use credential.helper manager to Store Your Password
  4. Conclusion
How to Configure Git Credentials to Recall Password and Username

This article outlines the process of configuring Git to recall your password and user name for git pull and git push commands. If you use HTTP(S) authentication, Git will always prompt you to enter your password when pushing or pulling.

Configure Git to Store Your Password

The easiest way to deal with Git asking for a password when pushing and pulling is employing SSH authentication instead of HTTPS. You only need to update your remote URL on the command line, as shown below.

Command:

$ git remote set-url origin git@github.com:username/repo.git

This method has a catch. It will disclose your username and password in many places.

Use credential.helper to Store Your Password

You can use Git’s Credential Helper to store your password.

Command:

$ git config --global credential.helper store

The command above will store your credential in a plain text file which is not entirely safe. You can set a timeout to remedy this using the following command.

Command:

$ git config --global credential.helper 'cache --timeout=3600'

This command will store your password for an hour.

Use credential.helper manager to Store Your Password

Alternatively, you can use Windows Credential Manager to store your password in your system’s safe storage.

Command:

$ git config --global credential.helper manager

Conclusion

In a nutshell, using HTTPS authentication requires you to provide Git with a password when pushing or pulling. You can configure Git to remember details, but storing your credentials on your machine is not always advisable.

Author: John Wachira
John Wachira avatar John Wachira avatar

John is a Git and PowerShell geek. He uses his expertise in the version control system to help businesses manage their source code. According to him, Shell scripting is the number one choice for automating the management of systems.

LinkedIn

Related Article - Git Credentials