Chandima Samarakoon
Chandima Samarakoon

Reputation: 409

How to overcome the git bash error occur when enable the two factor authentication in GitHub

Very recently I have activated the two-factor authentication on GitHub. Then after I tried to push my work (using git bash)to a new repository and it displays a error as the username or password is incorrect. How can I overcome this issue?

Upvotes: 1

Views: 516

Answers (1)

bk2204
bk2204

Reputation: 76409

It's likely that you're still using your username and password stored in a credential manager for pushing to GitHub, and that won't work when you're using two-factor authentication. The Git FAQ explains how to empty your credentials (replace your-username):

$ echo url=https://[email protected] | git credential reject

Then, the next time you push, Git will prompt your for your credentials. Go to https://github.com/settings/tokens and create a personal access token with the repo and workflow scopes, and then give Git your username when it asks and the personal access token for your password. Don't specify your actual password, since that won't work.

On Windows, you may see a graphical prompt to sign into GitHub; you can just close that window and follow the steps above.

Upvotes: 2

Related Questions