Linux git method of connecting with https without having to enter a password each time

  • 2020-11-26 19:03:43
  • OfStack

preface

Under command line we are accustomed to using 1 cases like ssh git operations, but in some cases can only can only be used when using https account password login every time push while waiting for the need to interact and git server suggested we enter account and password, often push and fetch when this operation is quite annoying, so how to preserve git password?

In this article to introduce you to the two implementation methods, the following words do not say much, to take a look at the details of the introduction

Method 1

First create.git-ES19en in the home directory, then type:


https://{username}:{password}@github.com 

If there are more than one, one for each row, :wq save exit

The command is then executed at the terminal


git config --global credential.helper store

If we see the following under the ~/.gitconfig file, we have succeeded


[credential]
helper = store

Method 2

This method requires the git version > =1.7.10, use git version to check the version number and see if it is supported. If it is not supported and you want to use it, then upgrade git version by yourself

Terminal down execution


git config --global credential.helper cache

By default, the password will be cached for 15 minutes, but if you want to change it for longer, say, an hour, you can


git config --global credential.helper 'cache --timeout=3600'

Here 3600 refers to seconds, the rest of the time to change

conclusion


Related articles: