Git push to avoid username and password

Source: Internet
Author: User
Tags net domain

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

  1. First, save your password in global configuration ,~ Add https: // {username }:{ passwd} @ git.coding.net
  2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.