This is the 16th day of my participation in the August Text Challenge.More challenges in August

The problem background

Little background

There was an error pulling code from and pushing code to GitHub. The error message is as follows:

$ git fetch
Logon failed, use ctrl+c to cancel basic credential prompt.
Username for 'https://github.com': username
Password for 'https://[email protected]':
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: unable to access 'https://github.com/liupjie/mybatis.git/': The requested URL returned error: 403
Copy the code

The background

GitHub announced last year (2020-07) that it was planning to validate Git operations with tokens for account security. From August 13, 2021, account password authentication will no longer be accepted. Therefore, the above error message appears.

  • Affected workflows
    • The Git command line
    • Desktop applications using Git (GitHub Desktop is not affected)
    • Any application or service that directly uses a password to access the GitHub repository

Problem solving

A, obtainpersonal access token

1. Log on to making

2. Click your profile picture in the upper right corner to enterSettings

3. Developer settings

4. Personal access tokens

5. Generate new token

  • Fill out the form
  • Note is a Note, will be inPersonal access tokensIn the list
  • The expiration time is optional (default 30 days)No expiration
  • I only selected the content related to the warehouse REPO, the rest depends on personal situation, arbitrary selection
  • Click at the bottom of the table when you’re doneGenerate TokenCan be

6. The generatedpersonal access tokenThe token is as follows

Make sure you copy the token or you won’t see it. You can only recreate one.

7. After refreshing the page, the token is not visible

  • The Note notes filled in the form just now will be displayed here

Set the token on the local machine

Windows system

1. Open the Control panel, locate the credential manager, and open it

2. Select the Windows credentials and find thegit:https://github.com, click Expand, and then click edit button

3. Replace the password with the token

Linux-based operation

If you are using Git from the command line, or on a Linux system, use the following method.

1. Configure the user name and email address

$ git config --global user.name "your_github_username"
$ git config --global user.email "your_github_email"
$ git config -l
Copy the code

2.gitWhen operating (e.g.git fetch) will prompt you to enter the username and password. In this case, you can enter the token as the password

3. Cache the token to the local PC

$ git config --global credential.helper cache
Copy the code

4. Delete the local token cache

$ git config --global --unset credential.helper
Copy the code

That’s GitHub’s introduction to the token verification update.