243

I was using a username password for pushing my code. It was working for several months, but suddenly I'm not able to do it and am getting this error:

Username for 'https://github.com': shreyas-jadhav
Password for 'https://shreyas-jadhav@github.com':
remote: Password authentication is temporarily disabled as part of a brownout. Please use a personal access token instead.
remote: Please see https://github.blog/2020-07-30-token-authentication-requirements-for-api-and-git-operations/ for more information.

Please note that the link doesn't help. Even using the generated token doesn't help.

Moderator Note: This is part of a planned and soon-to-be permanent service change by GitHub

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Shreyas Jadhav
  • 2,363
  • 4
  • 10
  • 23
  • 4
    GIthub are removing username password authentication, you need to use a token from now on – Liam Jun 30 '21 at 08:49
  • 21
    Reading [that web page basically tells you all of this...](https://github.blog/2020-07-30-token-authentication-requirements-for-api-and-git-operations/) – Liam Jun 30 '21 at 08:50
  • 20
    I have the same problem, and no, that page doesn't help. The problem is, even using a generated token as a password, the same error message appear. – Narann Jun 30 '21 at 09:28
  • I see the [doc](https://github.blog/2020-07-30-token-authentication-requirements-for-api-and-git-operations/): `Mid-2021 – Personal access or OAuth tokens will be required for all authenticated Git operations.` Maybe we just here? – yellowgray Jun 30 '21 at 09:46
  • You can install Github CLI -> https://cli.github.com/ if you want to avoid manual setup – Amir Saleem Jun 30 '21 at 10:19
  • 15
    Why on earth is the word "brownout" used?? – Ross Presser Jun 30 '21 at 18:00
  • 1
    Is there a status update from Github? I have no intention of doing this pain in the ass token bs. Temporary brownout message means this should be back up. I checked status but it lied and said all green. Bueller Bueller? – Michael Paccione Jun 30 '21 at 18:58
  • In the meantime, `git remote add not_broken_origin git@anywhere_but_github:repo` works fine too. – Eric Duminil Jul 01 '21 at 06:27
  • @MichaelPaccione You'd better read https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/. This was intentional and scheduled, and it will happen again in one month, and then in August it will become permanent. If you don't want to do it, fine, but you'll have to move your projects to another service. – Fabio says Reinstate Monica Jul 01 '21 at 09:32
  • 7
    @RossPresser A "brownout" is where you lose some, but not all, power. It's a throwback to the era of incandescent bulbs, where a small power loss could cause the bulbs to noticably dim. In this context, GitHub is "dimming the lights" to let everyone know about a pending change to the service (namely that passwords will stop working altogether soon). – Machavity Jul 01 '21 at 13:00
  • 1
    @RossPresser Wikipedia explains [brownout in software engineering](https://en.wikipedia.org/wiki/Brownout_(software_engineering)) to mean gradual disabling of partial functions of the service when the service is overloaded. --- Is github really overloaded, were they lazy to change the message or are they testing what will users tolerate? – pabouk - Ukraine stay strong Jul 01 '21 at 13:06
  • the linked question's answer is not a good approach. it is basically the same answer which as accepted here before. the currently accepted answer on this question explains. – Shreyas Jadhav Jul 01 '21 at 13:13
  • 1
    @ShreyasJadhav The main reason to close this as a duplicate is that it was getting lots of simple answers that were all saying the same thing. This leaves the question for others to find, read and vote on. – Machavity Jul 01 '21 at 13:20
  • Also useful is [this SuperUser question](https://superuser.com/q/378354/450209) which covers some additional ways to create and use a SSH key with Windows – Machavity Jul 01 '21 at 13:24
  • @Machavity i'm not asking why this closed. I meant to say is the answer posted on question you linked is an insecure way to solve this problem - as stated by GitHub. and the answers there are for 'unauthenticated server (Travis-CI)'. lot of people visiting here would just follow the link and get confused, and return back to get solutions for macOs, Windows and why the first answer not safe. which is think will just waste someones time. – Shreyas Jadhav Jul 01 '21 at 13:53
  • @FabiosaysReinstateMonica cross that bridge when it comes. – Michael Paccione Jul 01 '21 at 20:48
  • 1
    @pbauk, thanks for the relevant definition. I have never seen this term used with software before this; the Wikipedia page didn't even start being drafted until 4 years go. Github's blog from last year does use the term but doesn't define it. And they just threw it into the error message assuming we knew it already. That's rude. – Ross Presser Jul 02 '21 at 14:06
  • 1
    @Machavity thanks also for the definition. At age 54, I am thoroughly aware of the history of the term brownout regarding power; it's new to software engineering though, as [this ngram suggests](https://books.google.com/ngrams/graph?content=software+brownout&year_start=1800&year_end=2019&corpus=26&smoothing=3&direct_url=). – Ross Presser Jul 02 '21 at 14:08
  • 2
    This is not a duplicate of [Issue on adding SSH key to GitHub](https://stackoverflow.com/questions/35612504/issue-on-adding-ssh-key-to-github). Personal access tokens are a different access method from SSH keys. – Uyghur Lives Matter Aug 26 '21 at 17:46
  • Later developments: *[Support for password authentication was removed. Please use a personal access token instead](https://stackoverflow.com/questions/68775869)* – Peter Mortensen Sep 05 '21 at 12:04
  • We don't need 40 answers for this question. Many answers just repeat previous answers. – Peter Mortensen Sep 05 '21 at 13:14
  • The usual Microsoft forcing people to do things in ways they don't want to, "trust us you will prefer it this way". NO! I think its time to change to GitLab – run_the_race Oct 19 '21 at 20:21

25 Answers25

174
  1. Generate a new token from GitHub's developer settings

  2. Update the remote URL:

    git remote set-url origin https://<token>@github.com/<Git_URL>
    
  3. Pull once:

    git pull https://<token>@<Git_URL>.git
    

And you are good to go.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Kusal Shrestha
  • 1,643
  • 2
  • 13
  • 20
  • 1
    Try Github CLI -> https://cli.github.com/ . It does the deletion thing, you need to do OAuth only – Amir Saleem Jun 30 '21 at 10:20
  • 1
    For the "generate new token" step, which permissions/"scopes" do I enable for the new token? (I only want to enable the scopes needed for VSCode to push and pull from the repo properly) – Venryx Jun 30 '21 at 16:23
  • @Venryx Which ever you think as necessary. You can check it from here. https://docs.github.com/en/developers/apps/building-oauth-apps/scopes-for-oauth-apps – Kusal Shrestha Jun 30 '21 at 16:33
  • 15
  • 28
    This is not a good solution IMO. The issue here is that then the PAT is stored in plain text in the remote URL itself. So, if someone is able to gain access to the remote URL, they then have access to your PAT to do whatever with. The token should be securely stored in a Keychain or something of that nature. Edit: I specifically mean step 3, where you're adding the PAT as a prefix to the remote URL. – Kurtis Jungersen Jun 30 '21 at 16:46
  • @Ahmed4end The url where you clone the repo from. like https://github.com/kusalshrestha/react-native-mention.git – Kusal Shrestha Jun 30 '21 at 16:47
  • @KMJungersen you can post your solution here :) – Kusal Shrestha Jun 30 '21 at 16:50
  • 8
    hey guys you can set url of remote, instead of remove and add it. please use follow instruction```git remote set-url https://@github.com/``` – Leon Jun 30 '21 at 16:56
  • SSH keys are better – user253751 Jun 30 '21 at 17:05
  • 1
    A drawback is that this stores the token in plain-text within the origin url. It's better to store the token in your system's credential storage, as explained here: https://stackoverflow.com/a/68192394/2441655 – Venryx Jun 30 '21 at 17:15
  • @x-r everthing in the clone url except for https for example @github.com/USER/REPO.git – alex Jun 30 '21 at 17:47
  • I got `fatal: Couldn't find remote ref HEAD` error at the last step of this solution – lazarea Jun 30 '21 at 18:02
  • 1
    @Ahmed4end @x-rw `` is url to your repo github.com/yourname/yourrepo – YaMiN Jun 30 '21 at 18:06
  • 5
    There's no "git dev settings". I'd expect an answer with a golden badge to know the difference between git and GitHub. – Eric Duminil Jul 01 '21 at 06:24
  • @ShreyasJadhav: Use Credential Manager or similar secure storage for the token instead of saving it as plain text in the remote URL. – user2357112 Jul 01 '21 at 11:58
  • @user2357112supportsMonica could you post your ideal solution as an answer if you could? most of the answers are targeting only macOS. i would accept a single answer which compiles solutions for different OS' and work for most scenarios. – Shreyas Jadhav Jul 01 '21 at 12:39
  • 1
    else @KusalShrestha please edit your answer to mention the downsides of it too. – Shreyas Jadhav Jul 01 '21 at 12:40
  • 1
    @Ahmed4end What is ? For example, if your repo url is `https://github.com/Ben/MyDemo`, then your is `Ben/MyDemo`. – 无夜之星辰 Aug 16 '21 at 09:43
  • @Ahmed4end the git url is user_name/repo_name example `git remote set-url origin https://@github.com//` and then git push for existing repos. – Ian Poston Framer Apr 22 '23 at 17:23
143

The previously accepted answer, Kusal Shrestha's, does the job, but it is not safe because we store the token in plain text.

Storing it in the keychain is the better approach in my honest opinion.

For Visual Studio Code please read crg's answer.

For Windows:

You can try the @Venryx comment below, but I haven't tested it.


For Mac:

I just faced this issue now

Enter image description here

As suggested, I went to the development settings by following this URL and generated a token.

Then I went to my key chain access in my Mac:

Enter image description here

I deleted (all) the row for GitHub

Enter image description here

Now I went to the terminal and pushed dummy code

git push

Terminal asked me to enter the email and password for my account.

I entered my email, and, for the password, I entered the token that I generated earlier.

Enter image description here

And it started to work again.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Nagaraj Alagusundaram
  • 2,304
  • 2
  • 24
  • 31
  • 3
    On Windows, use "Credential Manager" rather than "Keychain Access". Also, make sure you use "Powershell" rather than Command Prompt, else it errors. See here for full instructions: https://stackoverflow.com/a/68192394/2441655 – Venryx Jun 30 '21 at 17:40
  • 1
    github should just add this post to their docs – Luke Schoenberger Jul 28 '21 at 18:42
  • 2
    You don't need to delete the Keychain, you can just edit the password and add the token – Pietro Nadalini Jul 28 '21 at 20:24
  • This method will replace your Safari login credentials for github.com, which in turn will likely break future third party oauth approvals depending on the token permissions. – Joshua Kolden Aug 16 '21 at 20:22
45

Solution for macOS

I just followed the following instructions and that's solved my issue.

  1. Generate a personal access token for GitHub. Process to generate token
  2. Open your Keychain Access.
  3. Search for github.com and double click on that.
  4. Update the password with the key you've generated recently.

N.B: I'm not sure this will work for other operating system users.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Sifat Haque
  • 5,357
  • 1
  • 16
  • 23
  • On Windows, use "Credential Manager" rather than "Keychain Access". Note that you may also need to change your git `origin` to include your username (otherwise it errors, for me at least). See here for full instructions: https://stackoverflow.com/a/68192394/2441655 – Venryx Jun 30 '21 at 17:53
  • This worked on macOS for me https://stackoverflow.com/a/68192584/7942242 – crg Jul 28 '21 at 11:32
  • This solution was the only one that worked for me after Aug 13. Updating remote URL solution did not work, in my case. – user1791914 Aug 13 '21 at 18:45
36

Here is a simple solution:

  • Go to GitHub → SettingsDeveloper settingsPersonal access tokens. Regenerate your token and copy it.
  • On any of your local repositories, when git push, enter your username, and the password is the generated token

Instead of manually entering your token for every HTTPS Git operation, you can cache your token with a Git client.

  • In a terminal, enter the following:
# Set Git to use the credential memory cache
git config --global credential.helper cache
  • To change the default password cache timeout, enter the following:
# Set the cache to timeout after 1 hour (setting is in seconds)
git config --global credential.helper 'cache --timeout=3600'
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
dpacman
  • 3,683
  • 2
  • 20
  • 35
  • 2
    This was the best answer...but one additional step. Before this I had to set "git config --unset credential.helper"...then I entered "git config --global credential.helper cache", then I was good. I had to enter my username/newkey one last time...then I was good. – user2662680 Jul 28 '21 at 18:24
  • 1
    "the password is the generated token" This was the part I was missing! – Jaggler3 Aug 13 '21 at 20:41
26

Password authentication is disabled by GitHub and is not supported any more. Create and use a personal access token (PAT) instead of a password.

Steps to follow:

  1. Remove GitHub stored credentials from the keychain. (For example, using "Keychain Access" on Mac, or "Credential Manager" on Windows)
  2. Generate access-token from GitHub SettingsDeveloper SettingsPersonal access tokensGenerate new token
  3. Save the token - as it will be available there for once only
  4. Run command git fetch (or git push, if fetching doesn't require permissions)

    If on Windows, you must run this from PowerShell, not the command prompt (CMD). The command prompt consistently fails with the remote: Password authentication is temporarily disabled message, despite identical inputs.

  5. It will ask for your user name and password.

    If it does not ask you for your username and password, you must change your Git remote URL to contain your username: https://USERNAME@github.com/repo-owner/repo-name.git (see approach 2 for instructions on changing remote URL)

  6. Use the access token instead of the password when it asks for a password (you will have to enter it twice)

Or the second approach:

  1. Generate access-token from GitHub: SettingsDeveloper SettingsPersonal access tokensGenerate new token
  2. Update the URL for origin locally: git remote set-url origin https://<token>@<git_url>.git
  3. Pull once: git pull https://<token>@<git_url>.git
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Avneesh Agrawal
  • 916
  • 6
  • 11
  • 1
    This worked for me just now, not sure why it's being downvoted. Just use your usual github user name along with the access token from below guide in stead of your password. https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token – Lewis Jun 30 '21 at 10:01
  • I think the first step is most important. If you skip, the error still appear. – Kino Jun 30 '21 at 10:01
  • 4
    Or even better, an SSH key – user253751 Jun 30 '21 at 17:05
  • Note: The approach above worked for me, but **only when run from Powershell**. When I run it from regular Command Prompt, it fails every time. (I have confirmed this 5+ times now) – Venryx Jun 30 '21 at 17:12
  • 1
    I've done more testing, and found another condition: The approach above (#1) **only works if the Git url contains your username**. For example, this works: `https://ME@github.com/ME/my-repo.git` But this does not: `https://github.com/ME/my-repo.git` – Venryx Jun 30 '21 at 17:23
19

Works for macOS, Windows and Linux

Solution 1

  1. Delete the existing repository (if you have any current changes, make a backup of it):

    mv my-repo my-repo.backup
    
  2. Create an SSH key and add it to GitHub (see GitHub documentation)

  3. Clone the repository for SSH: git clone git@github.com:group/repo-name.git

Solution 2 (recommended solution)

  1. git remote remove origin

  2. You have to add an access token (see GitHub documentation to generate a token)

  3. git remote add origin https://<token>@<git_url>.git

  4. git pull https://<token>@<git_url>.git

Using Visual Studio Code

  1. Remove your GitHub access:
git credential-osxkeychain erase
⏎  host=github.com
⏎  protocol=https
  1. git push or git pull

    It will prompt you with a modal dialog. Click Allow and follow the process.

crg
  • 4,284
  • 2
  • 29
  • 57
16

If you're using macOS

  1. First please delete all GitHub credential in the keychain and then please generate your token for use as your password instead (due to GitHub security policy): GitHub* → SettingsDeveloper settingsPersonal access token.

  2. Try to push or pull some things latest to/from your repository. Then Git will ask you for username and password. Enter your username and your generated token from GitHub.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
ivrylobs
  • 173
  • 6
  • Guide by GitHub: https://docs.github.com/en/get-started/getting-started-with-git/updating-credentials-from-the-macos-keychain – Arnold Oosterom Jun 30 '21 at 10:03
  • 2
    Alternatively, in keychain Access.app search for "github" and find the entry with the Kind listed as "Internet Password" (you may have entries for "Web form password" these are not what the terminal is using). Double click the entry to edit it. Check the box to "Show password". Replace the password with a github token. Click "Save Changes". You should now be able to do everything as before. Hope that's helpful. – Hunter Jun 30 '21 at 16:40
  • It's important to note that there are two "hidden conditions" for this to work: 1) Your git remote url must contain your username, eg. `https://USERNAME@github.com/...`, 2) On Windows, you must use Powershell rather than Command Prompt. For more details, see here: https://stackoverflow.com/a/68192394/2441655 – Venryx Jun 30 '21 at 17:30
  • This worked on MacOS intel and m1 for me https://stackoverflow.com/a/68192584/7942242 – crg Jul 28 '21 at 11:31
12

I tried every method, and finally it worked for me. I was unable to push in my repository because of this error, so please at least once try this!

_____________________________generate the personal access token:

  1. Click here and generate a personal access token. It's damn easy.

    https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token

    Now simply push it with the help of the PAT rather than password and username___________________

  2. To push changes to your repository:

    git push https://[Personal Access Token]@github.com/[User Name]/[Repository Name].git
    
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Saikat Mukherjee
  • 500
  • 5
  • 11
10

If you are using HTTPS

  • Generate a token in your token settings as indicated in the documentation

  • If the repository already exists, you must then change your remote URL in the format: https://<username>:<token>@github.com/<repository_url>

    git remote remove origin
    git remote add origin https://<USERNAME>:<TOKEN>@<GIT_URL>.git
    git pull # Verify
    
  • If you clone your repository

    git clone https://<USERNAME>:<TOKEN>@<GIT_URL>.git
    
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
E-jarod
  • 275
  • 2
  • 13
7
  1. Create a personal access token

  2. On your Visual Studio Code command line:

    git config --global credential.helper [YOUR_TOKEN]
    
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jaeyoung0
  • 71
  • 2
  • 2
    Note: This will not work if you've already set up git to read from your system credential manager, rather than hard-coded entries in your git config. Unfortunately, git does not warn you of this, so just silently fails, as it uses the outdated credential-manager entry rather than the new access-token added by the command above. To add the access-token to your system credential manager, see here: https://stackoverflow.com/a/68192394/2441655 – Venryx Jun 30 '21 at 17:28
5

Solution for Ubuntu Server and an existing Git repository

Remove the password:

git config --global --unset user.password;
git config --local --unset user.password;

Change remote.origin.url. replace <username> by your GitHub username:

git config --global --replace-all remote.origin.url "https://<username>@github.com/PPEProjects/smile-eyes-be.git";
git config --local --replace-all remote.origin.url "https://<username>@github.com/PPEProjects/smile-eyes-be.git"

Pull/push

git pull
git push origin HEAD:develop

Enter the personal access tokens generated from Personal access tokens.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tien Nguyen
  • 106
  • 6
4

Try this (it worked for me):

  1. Generate an SSH key with this guide: Generating a new SSH key
  2. Remove all old remotes that use HTTPS with git remote remove origin;
  3. Add a new remote using an SSH reference (you can get it with the "code" button in your repository and then press "ssh").

enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
4

First from the post: Token authentication requirements for API and Git operations, it said

Mid-2021 – Personal access or OAuth tokens will be required for all authenticated Git operations.

So you need to use a personal access token (PAT) to push:

1 Get your personal access token

Login here to access the repository and add a new personal access token: Personal access tokens. Generate one and keep the token safe (it can't be shown once you leave).

(In Android Studio, you need to get the permission of "repo", "gist" and "read:org")

2 Push with the personal access token

After you get the token, you can push with a command like:

git push https://[personal access token]@github.com/[user name]/[repository Name].git
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
yellowgray
  • 4,006
  • 6
  • 28
  • Thanks for posting this because it is adaptable to gists, too, as `git push https://[Personal Access Token]@gist.github.com/[Gist ID].git` . I needed this because despite checking `create` gists the options when creating my token, and repo interaction working with git, pushing to gists wasn't working after August 13, 2021. – Wayne Aug 24 '21 at 17:40
3

All you have to do is use a generated token instead of a traditional password:

Old method using a password:

git clone https://github.com/username/repo.git

Username: your_username
Password: your_password

New method using a token:

git clone https://github.com/username/repo.git

Username: your_username
Password: your_token

Step 1: Generating an API token from GitHub

Step 2: Replacing your previous cached password with the newly generated token

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Blaze Clone
  • 101
  • 3
  • 8
3

I received this error when trying to push up in Visual Studio Code... But I opened up Terminal and pushed up no problem using a username and password.

It might be something you could try.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
JoRoFo
  • 71
  • 5
3

This worked for me:

  1. Generate the personal access token (don't forget to copy the token)

  2. Open your Keychain Access (Mac) or Credential Manager (Windows).

  3. Update the GitHub password with the new personal access token in KeyChain Access/Credential Manager

  4. Last step: Do a Git clone (make sure you clone the repository in the proper directory location)

    git clone https://github.com/username/repo.git
    
    Username: your_username
    Password: your_token
    

In my case it did not prompt me for the username and password as it was already updated in Keychain Access.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Yeshi
  • 281
  • 3
  • 5
2

GitHub is removing username password authentication

An alternative approach to what others have mentioned:

You can install and configure GitHub CLI. It is much better to set up using OAuth. There isn't any need to manually remove the credentials from the keychain.

On macOS with Homebrew (brew), the installation is even simpler:

Run brew install gh and follow the following:

  1. What account do you want to log into? GitHub.com, choose GitHub
  2. What is your preferred protocol for Git operations? Choose HTTPS
  3. Authenticate Git with your GitHub credentials? Choose YES
  4. How would you like to authenticate GitHub CLI? Choose Login with a web browser
  5. Copy the code shown in terminal -> B7C1-8E67
  6. Press Enter to open github.com in your browser
  7. Authenticate using the browser

Done.

Start using Git commands as you usually do.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Amir Saleem
  • 2,912
  • 3
  • 21
  • 35
2

The following steps worked perfectly fine for me

Steps to follow:

  • Generate an access token from GitHub, SettingsDeveloper SettingsPersonal access tokensGenerate new token

  • Save the token - as it will be available there for once only

  • Search for the .git-credential file in the system

  • Use the access token instead of the password in that file after the username.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
2

There is also a very neat script that is helpful to convert HTTPS cloned Git repositories to use ssh protocol without removing and cloning the Git repository:

Convert HTTPS GitHub clones to use SSH

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Remo
  • 53
  • 6
  • 1
    I didn't have luck with the first script, but this one in the comments worked perfectly: https://gist.github.com/m14t/3056747#gistcomment-3468753 – JP. Jun 30 '21 at 18:38
1

If you're using the HTTPS version instead of SSH one then this error will come because GitHub is removing the HTTPS method to maintain repositories.

  1. Generate an SSH key if you haven't by ssh-keygen and keep on hitting Enter till ends
  2. cat ~/.ssh/id_rsa.pub - copy the result
  3. Visit https://github.com/settings/keys
  4. Press New SSH Key and paste the key in the textbox. The title can be anything you want
  5. cd <into your project's directory>
  6. git remote set-url origin git@github.com:<username-here>/<repository-name-here>.git

And you're good to go!

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Yash Pokar
  • 4,939
  • 1
  • 12
  • 25
1

You can generate your PAT (personal access token) via your GitHub dashboard.

  • Step 1: Log in to your GitHub account.

  • Step 2: In the upper-right corner of any page, click your profile photo, then click Settings.

  • Step 3: In the left sidebar, click Developer settings.

  • Step 4: In the left sidebar, click Personal access tokens.

  • Step 5: Click Generate new token.

  • Step 6: Give your token a descriptive name.

  • Step 7: Select the scopes, or permissions. You'd like to grant this token. To use your token to access repositories from the command line, select repo.

  • Step 8: Click Generate token.

Copy your token to a safe location as once you get out of that page you will not be able to retrieve it, unless you create a new one.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
stanley mbote
  • 956
  • 1
  • 7
  • 17
1

You don't need to remove the remote. Add a new one and then pull (as suggested by the accepted answer).

The simplest solution that worked for me (on Linux) was to use gh auto login and follow the CLI instructions. No further steps were required.

If you don't have gh, install it following this link, depending on your OS.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
uber
  • 4,163
  • 5
  • 26
  • 55
  • The best Way to fix the error is Go to the project directory, and open the ."git" the open the "config" file and remove the following lines: -------- [credential] helper = store ---------- Now try git pull or push you will see enter username password screen this time enter github token instead of password. – user3512810 Jul 28 '21 at 09:32
1

If you don't want to store your token in plain text (by modifying the remote repo's URL), you can do this:

  1. Generate a new token by following the official link
  2. Make sure you copy the token by clicking on the following button. If you double click on the text and copy it, it will add an extra space and you'll keep getting the same error (even though you're not using your password anymore, but the token)

enter image description here

Oscar Mederos
  • 29,016
  • 22
  • 84
  • 124
0

Fast hot fix

Go to Personal access tokens and regenerate the last token:

Enter image description here

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Petr
  • 224
  • 2
  • 16
-6

I faced this problem this afternoon and solved it by replacing my GitHub password on my computer as described in reference 3 with generated token from reference 2.

  • Reference 1: See Token authentication requirements for API and Git operations. The password is not supported anymore.

  • Reference 2: So you should generate a token with this tutorial and use it to replace your password as a credential.

  • Reference 3: If you are not prompted for your username and password, your credentials may be cached on your computer. You can update your credentials in the Keychain to replace your old password with the token as described in this tutorial.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Lebecca
  • 2,406
  • 15
  • 32
  • Use SSH with RSA keys. ```ssh-keygen -t rsa -b 4096 -C "github_account_email" ```. This will generate two RSA keys one with a `.pub` extension put it in github as this is the public token and keep the private token in your local machine and from now whenever you push you will use ssh in place of going through https connection – Soumalya Bhattacharya Jun 30 '21 at 21:04