Languages
[Edit]
EN

Git - save password under Linux

9 points
Created by:
Marcin
15470

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

Read below section to know details about quick solution and alternatives.

1. git credintial store example

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

Simple steps:

  1. run terminal,
  2. run following command:
    git config credential.helper store
  3. run following command in project directory:
    git pull
    or any other git command that requires authentication,
  4. we will be asked to provide username and password to our git account - do it and confirm 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 posible to cache password password only for some time. That approach keeps password only inticated amount of the time - so we need to type password only when idle time is bigger than inidicated in configuration.

Use following command:

git config --global credential.helper cache

or with time of password storing (in seconds):

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

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

References

  1. Git config - docs
Native Advertising
50 000 ad impressions - 449$
🚀
Get your tech brand or product in front of software developers.
For more information contact us:
Red dot
Dirask - friendly IT community for everyone.

â€ïžđŸ’» 🙂

Join