Languages
[Edit]
EN

Git - save password under Linux

9 points
Created by:
sienko
683

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

or:

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.

References

  1. Git config - docs

Alternative titles

  1. Git - save username and password on Linux
  2. How do I save git credential under Linux?
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Git

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.

❤️💻 🙂

Join