EN
Git - save username and password on windows
12
points
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 the below sections we can see described two variants:
- built-in in operating system Windows Credential Manager,
- git credential store.
1. Windows Credential Manager example
This approach uses Windows Credential Manager that stores passwords in operating system safe storage.
Simple steps:
- run Git Bash,
- run following command:
git config --global credential.helper manager
- run following command in the project directory:
git pull
- Windows Credential Manager will ask us for username and password,
- type username and password and click Ok or other confirmation action,
- all future git authentications for this git account will go from Windows Credential Manager.
Notes:
- now our password is saved with Windows Credential Manager - not as plain text
- Available from Git for Windows 2.7.3+ - github release
2. git credential store example
This approach uses git credential store that stores passwords in a simple text file.
Simple steps:
- run Git Bash,
- run following command:
git config credential.helper store
- run following command in the project directory:
git pull
- we will be asked to provide username and password to our git account,
- type username and password and click Ok or other confirmation action,
- 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.