Preface
When you use GitHub, you must enter the GitHub account and password every time you push and pull, this not only wastes a lot of time and reduces work efficiency. In this context, this article finds two ways on the Internet to avoid this situation. These results are also proposed by our predecessors. Here we just make a summary.
1. method 1
1.1 create a git user name and password for the file store
In the % home % directory, it is generally c: \ Users \ administrator, or you can create your own system username Directory, which is always in c: \ Users. The file name is. git-credentials, because it is not allowed to directly create ". "file, so you need to use git Bash to open the GIT bash client, run the % home % directory, and then use touch to create the file. git-credentials: Use Vim to edit the file and enter the content format:
touch .git-credentials
vim .git-credentials
Https: // {username }:{ password} @ git.coding.net // The coding.net domain name is used here.
For the SSH protocol, configure the SSH public key and use the SSH protocol. For details, see SSH Public Key configuration.
For https
- First, save your password in global configuration ,~ Add https: // {username }:{ passwd} @ git.coding.net
- Then configure the GIT command storage authentication,
1.2 add git config content
Enter the GIT bash terminal and enter the following command:
git config --global credential.helper store
After execution, check the. gitconfig file in the % home % directory. An additional item is displayed:
[credential] helper = store
If you enable git bash again, you will find that you do not need to enter the user name and password for git push.
2. method 2
2.1 Add Environment Variables
Add a home environment variable in Windows. The variable name is home. The variable value is % USERPROFILE %.
2.2 create a git user name and password storage file
Go to the % home % directory and create a new file named "_ netrc" in the following format:
machine {git account name}.github.comlogin your-usernmaepassword your-password
Open git bash again without entering the user name and password
Git push to avoid username and password