After enabling Two Factor Authentication (2FA), you may see something like this when attempting to use git clone
, git fetch
, git pull
or git push
:
$ git push origin master
Username for 'https://github.com': your_user_name
Password for 'https://[email protected]':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/your_user_name/repo_name.git/'
From the GitHub Help documentation:
After 2FA is enabled you will need to enter a personal access token instead of a 2FA code and your GitHub password.
...
For example, when you access a repository using Git on the command line using commands like
git clone
,git fetch
,git pull
orgit push
with HTTPS URLs, you must provide your GitHub username and your personal access token when prompted for a username and password. The command line prompt won't specify that you should enter your personal access token when it asks for your password.
Related question: https://stackoverflow.com/a/21374369/101662