diff --git a/Contributors.md b/Contributors.md index 2c4b71eb..00f608e8 100644 --- a/Contributors.md +++ b/Contributors.md @@ -1063,6 +1063,7 @@ - [ctran](https://github.com/ctran414) - [Xeplon](https://github.com/Xeplon) - [koanuywg](https://github.com/koanuywg) +- [Jagpreet Grewal](https://github.com/JagpreetGrewal) - [danesusername](https://github.com/danesusername) - [Rajat Bhosale](https://github.com/RajatBhosale) - [Charandeep Singh](https://github.com/charandeepsinghb) diff --git a/additional-material/git_workflow_scenarios/additional-material.md b/additional-material/git_workflow_scenarios/additional-material.md index ca06d812..2fb9f639 100644 --- a/additional-material/git_workflow_scenarios/additional-material.md +++ b/additional-material/git_workflow_scenarios/additional-material.md @@ -46,4 +46,7 @@ This document provides information about how to undo a commit on your local repo This document is dedicated to all the tips and tricks websites, blog posts, and helpful sites that make our lives easier. They are a great reference to serve all of our needs, be it a beginner or an expert. This page should act as an index of all those useful links that would help everybody who is new in the open-source domain or someone who wants to learn more. ### [Creating a .gitignore file](creating-a-gitignore-file.md) -This document explains what a .gitignore file does, why to use it and how to create a .gitignore file. This file is used in almost all git projects. It helps commit only the necessary files to git. +This document explains what a .gitignore file does, why to use it and how to create a .gitignore file. This file is used in almost all git projects. It helps commit only necessary files to git. + +### [Storing Credentials](storing-credentials.md) +This document explains how to store your credentials for repositories. This can be a security concern, so please follow the security policies of your place of work/study. diff --git a/additional-material/git_workflow_scenarios/storing-credentials.md b/additional-material/git_workflow_scenarios/storing-credentials.md new file mode 100644 index 00000000..e9f3c10e --- /dev/null +++ b/additional-material/git_workflow_scenarios/storing-credentials.md @@ -0,0 +1,48 @@ +# Storing Credentials + +You might have complained about this before - entering your username and password each time you access the repository can be a hassle and can interrupt your workflow if it takes too long. But it doesn't need to be that way. + +We will be covering one of the methods available to us - [git credential cache](https://git-scm.com/docs/git-credential-cache). + +**Note:** Please follow the security policies of your place of work/study. + +## Caching + +We can use git credential cache to store our username and password. + +**Attention:** This method saves the credentials in *plaintext* on your PC's disk. Everyone on your computer can access it, e.g. malicious NPM modules. + +### Global Credential Cache + +If we wish to, we can store the credentials for every repository we are working with using one simple command: + +``` +$ git config --global credential.helper cache +``` + +**Reminder:** Please follow the security policies of your place of work/study. + +### Repository Credential Cache + +We can store the credentials for the repository we are working with using one simple command, similar to before: + +``` +$ git config credential.helper cache +``` + +**Reminder:** Please follow the security policies of your place of work/study. + +### Cache Timeout + +If we do not specify a length of time to store our credentials, they can potentially be stored forever. However, we can determine how long they will be kept in memory using this command: + +``` +git config credential.helper 'cache --timeout=' +``` + +Using the helper, the credentials will never touch the disk and will be erased after the specified timeout. The default value is 900 seconds (15 minutes). + +#### References +[Stack Overflow](https://stackoverflow.com/questions/35942754/how-can-i-save-username-and-password-in-git) + +### [Additional Material](additional-material.md) \ No newline at end of file