Languages
[Edit]
EN

Git - save username and password on windows

9 points
Created by:
Marcin
2478

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

Quick solution (run command):

git config --global credential.helper manager

In below sections we can see described two variants:

  • built-in in operating system Windows Credential Manager,
  • git credintial store.

1. Windows Credential Manager example

This approach uses Windows Credintial Manager that stores passwords in operating system safe storage.

Simple steps:

  1. run Git Bash,
  2. run following command:
    git config --global credential.helper manager
  3. run following command in project directory:
    git pull
    or any other git command that requires authentication,
  4. Windows Credential Manager will ask us for username and password,
  5. type username and password and click Ok or other confirmation action,
  6. all future git authentications for this git account will go from Windows Credential Manager.

Notes:

2. git credintial store example

This approach uses git credintial store that stores passwords in simple text file.

Simple steps:

  1. run Git Bash,
  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,
  5. type username and password and click Ok or other confirmation action,
  6. all future git authentications for this git account will go from .git-credentials file.

Note: the password is stored as plain text in C:\Users\my_user_name\.git-credentials what is not safe when our account is not encrypted.

References

  1. Git Credential Manager for Windows
  2. Windows Credential Manager
  3. Git config - docs
Hey 👋
Would you like to know what we do?
  • Dirask is a friendly IT community for learners, professionals and hobbyists to share their knowledge and help each other in extraordinary easy way.
  • We welcome everyone,
    no matter what the experience,
    no matter how basic the question is,
    this community will help you.