I recently began using two-factor authentication on GitHub, and I am now unable to use git over https on private repos in the usual way:
peter@computer:~$ git clone https://github.com/[...]/MyPrivateRepo
Cloning into 'MyPrivateRepo'...
Username for 'https://github.com': [...]
Password for 'https://[...]@github.com':
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/[...]/MyPrivateRepo/'
If I disable two-factor authentication I can use it as before:
peter@computer:~$ git clone https://github.com/[...]/MyPrivateRepo
Cloning into 'MyPrivateRepo'...
Username for 'https://github.com': [...]
Password for 'https://[...]@github.com':
remote: Counting objects: 147, done.
remote: Total 147 (delta 0), reused 0 (delta 0), pack-reused 147
Receiving objects: 100% (147/147), 22.70 KiB | 0 bytes/s, done.
Resolving deltas: 100% (87/87), done.
Checking connectivity... done.
I know I can use SSH and everything works, but is there a way I can keep two-factor authentication while still being able to use GitHub over HTTPS, for example by sending an auth token with my request?