Use token to push some code to GitHub - "Support for password authentication was removed" [duplicate]

Solution 1:

GitHub announced their intent to require the use of token-based authentication for all authenticated Git operations. They will no longer accept account passwords when authenticating Git operations on GitHub.com:

Generate token:

  • Go to your GitHub account token settings
  • Generate a token

On Mac:

  • Go to keychain Access
  • Press the Login tab and all items
  • Click GitHub key
  • Change the password to the recent generated token

Enter image description here

On Windows:

  • Go to Control PanelUser AccountsCredential Manager

  • Edit the Generic Credential of GitHub

  • Paste the token instead of the password

Enter image description here

Solution 2:

You need to change the remote URL with:

git remote set-url <stream> https://<token>@github.com/<username>/<repo>

token can be found here.

Solution 3:

I also encounter this problem today, on macOS.

I solve this problem by:

First, get a token! Follow the guidance of GitHub. I think you can just click the link provided in the warning.

Second, change the key chain on macOS:

  1. Search "Keychain" on macOS.
  2. Search "GitHub".
  3. Change the password in the one that with "Internet Password", using your new token.

Then, my problem is solved and I can "git push" now.

Solution 4:

Step 1: Go to your GitHub account → SettingsDeveloper settingsPersonal access tokens → Generate / regenerate your token

Step 2: Go to https://cli.github.com and download GitHub CLI

Step 3: Go to your command line or Terminal → gh auth login and follow with login credentials. Done.