Git - save password under Linux

9 points
Created by:

In this article, we want to show how to save username and password for gitĀ under Linux when we don't want to type it each time during push / pull operations.

Quick solution (run following command):

git config credential.helper store


git config --global credential.helper store

Where: --global causes saving the password in a common place (only forĀ logged-in user).


Read the below section to know details about quick solutions and alternatives.

1. git credential store example

This approach uses git credential store that stores passwords in simple plain text fileĀ - it is not safe when the file system is not encrypted.

Simple steps:

  1. run terminal,
  2. run following command:
    git config credential.helper store
  3. run following commandĀ in the project directory:
    git pull
    or any other git command that requires authentication,
  4. we will be asked to provide aĀ username and password to our git account - do it andĀ confirm the action,
  5. future git authentications for this git account will useĀ .git-credentials file.

Note: path to passwords location isĀ ~/.git-credentials.

2. Cached passwords

It is possible to cache passwords only for some time. That approach keeps passwords only indicated amount of the time - so we need to type password only when idle time is bigger than indicated in configuration.

Use the following command:

git config credential.helper cache

or with a time of password storing (in seconds):

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

WhereĀ --timeout=3600 means keeping the password 1 hour.


  1. Git config - docs


Native Advertising
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

ā¤ļøšŸ’» šŸ™‚