gitHub can't push with a password, you must use a token

It’s been a while since I used github to push the project. After pushing today, I entered the account password according to the prompt, but failed, and the error is as follows:

support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/skrqwa/test.git/'
wenanqin@WenandeMacBook-Air test % 

The general meaning of the first sentence is that the original password certificate will not be available from August 13, 2021. How to do it? The solution is to use a personal access token, which is to replace the password with a token for verification.

1. What is token (token)

Token is when the client frequently requests data from the server, and the server frequently goes to the database to query the user name and password and compares them to judge whether the user name and password are correct or not, and make corresponding prompts. In this context, Token came into being .
Token is a string of strings generated by the server as a token for the client to request. After logging in for the first time, the server generates a Token and returns the Token to the client. In the future, the client only needs to bring this Token can come to request data, no need to bring user name and password again.
The purpose of Token is to reduce the pressure on the server, reduce frequent database queries, and make the server more robust.

2. The characteristics of the token

unique: tokens are specific to github and can be produced per use and device revocable
: tokens can be revoked individually at any time without updating unaffected data
limited: tokens can be narrowed to allow access only for use cases

3. How to generate your own token on github

1. Click on the settings of github
insert image description here

2. Pull down and select the developer settings developer settings
insert image description here

3. Select the token (classic) under personal access tokens, and then generate new token
insert image description here

4. Set the validity period of the token, access rights, etc.

  • Access warehouse permissions, select repo
  • To delete warehouse permissions, select delete_repo

insert image description here
insert image description here
5. Save the generated token (a string of characters), and it will disappear after refreshing the webpage next time
insert image description here

3. Use token to push

Paste your token where you entered the password to perform the push operation.
You can also add the token directly to the remote warehouse link, so that you can avoid entering the token every time the same warehouse submits code:

git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git
  • <your_token>: replace it with the token you got yourself
  • < USERNAME >: is your own github username
  • <REPO>: is your repository name

Original link: https://blog.csdn.net/qq_41646249/article/details/119777084

Guess you like

Origin blog.csdn.net/weixin_42907822/article/details/128155118