How to save username and password in GIT [GitExtension]?


I want to use a push and pull automatically in GitExtension, without entering my user and password in a prompt, every time.

So how can I save my credentials in GIT?

6/11/2020 7:50:22 PM

Accepted Answer


git config --global credential.helper store


git pull

provide a username and password and those details will then be remembered later. The credentials are stored in a file on the disk, with the disk permissions of "just user readable/writable" but still in plaintext.

If you want to change the password later

git pull

Will fail, because the password is incorrect, git then removes the offending user+password from the ~/.git-credentials file, so now re-run

git pull

to provide a new password so it works as earlier.

8/29/2019 1:02:03 AM

You can use the git config to enable credentials storage in git.

git config --global credential.helper store

When running this command, the first time you pull or push from the remote repository, you'll get asked about the username and password.

Afterwards, for consequent communications with the remote repository you don't have to provide the username and password.

The storage format is a .git-credentials file, stored in plaintext.

Also, you can use other helpers for the git config credential.helper, namely memory cache:

git config credential.helper cache <timeout>

which takes an optional timeout parameter, determining for how long the credentials will be kept in memory. Using the helper, the credentials will never touch the disk and will be erased after the specified timeout. The default value is 900 seconds (15 minutes).

WARNING : If you use this method, your git account passwords will be saved in plaintext format, in the global .gitconfig file, e.g in linux it will be /home/[username]/.gitconfig

If this is undesirable to you, use an ssh key for your accounts instead.


Recommended and Secure Method: SSH

Create an ssh Github key. Go to -> Settings -> SSH and GPG keys -> New SSH Key. Now save your private key to your computer.

Then, if the private key is saved as id_rsa in the ~/.ssh/ directory, we add it for authentication as such:

ssh-add -K ~/.ssh/id_rsa

A More Secure Method: Caching

We can use git-credential-store to cache our username and password for a time period. Simply enter the following in your CLI (terminal or command prompt):

git config --global credential.helper cache

You can also set the timeout period (in seconds) as such:

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

An Even Less Secure Method

Git-credential-store may also be used, but saves passwords in plain text file on your disk as such:

git config credential.helper store

Outdated Answer - Quick and Insecure

This is an insecure method of storing your password in plain text. If someone gains control of your computer, your password will be exposed!

You can set your username and password like this:

git config --global "your username"

git config --global user.password "your password"

Turn on the credential helper so that Git will save your password in memory for some time:

In Terminal, enter the following:

# Set git to use the credential memory cache
git config --global credential.helper cache

By default, Git will cache your password for 15 minutes.

To change the default password cache timeout, enter the following:

# Set the cache to timeout after 1 hour (setting is in seconds)
git config --global credential.helper 'cache --timeout=3600'

From GitHub Help


You can edit the ~/.gitconfig file to store your credentials

sudo nano ~/.gitconfig

Which should already have

        email = [email protected]
        user = gitUSER

You should add at the bottom of this file.

        helper = store

The reason I recommend this option is cause it is global and if at any point you need to remove the option you know where to go and change it.


Then when you pull | clone| enter you git password, in general, the password will be saved in ~/.git-credentials in the format

https://GITUSER:[email protected]


See Docs

Restart your terminal.


Just put your credentials in the Url like this:

You may store it like this:

git remote add myrepo https://Userna...

...example to use it:

git push myrepo master

Now that is to List the url aliases:

git remote -v

...and that the command to delete one of them:

git remote rm myrepo