How Can I Save Username and Password in Git

Git is a widely used version control system for software development.

It’s essential for developers to manage their code and collaborate with others.

However, when using Git on the command line, users are often prompted for their username and password every time they interact with a remote repository.

This can be frustrating and time-consuming, especially if you’re working with Git frequently.

Fortunately, there’s a way to save your Git username and password to make your Git workflow smoother.

In this article, we’ll explore two methods to save Git usernames and passwords.

Method 1: Git Credential Store

Git provides a feature called the “Git Credential Store” which enables users to save their usernames and passwords for a specified period of time.

By default, the Git Credential Store will save your credentials for 15 minutes.

However, you can configure this time to your preferred value by using the following command:

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

In the command above, 3600 represents the number of seconds you want the credentials to be cached. For example, if you set 3600, your credentials will be saved for one hour.

Method 2: Git Config

Another option to save Git usernames and passwords is by using the git config command.

This method saves your credentials in plain text in the Git configuration file, which is located in your home directory.

To save your Git username and password using this method, use the following commands:

git config --global "Your Name"
git config --global "[email protected]"

Replace “Your Name” with your actual name and “[email protected]” with your email address.

The Git username and email address you set will be saved in the Git configuration file and will be used for all your Git interactions.

It’s important to note that saving your Git credentials in plain text in the Git configuration file can be a security risk.

If someone gains access to your computer, they will be able to see your Git username and password.

Therefore, it’s recommended to use the Git Credential Store method.


In this article, we discussed two methods to save Git usernames and passwords, the Git Credential Store and the Git Config.

By using these methods, you can avoid having to enter your credentials every time you interact with a remote repository, making your Git workflow smoother and more efficient.