Two factor authentication and access tokens with github

1 May 2020

With 2FA and a personal access token set up the way to initialise a repo locally and then push up to github is slightly different

Instead of something like:

echo "# git push without 2FA and personal access token" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/$USERNAME/$REPONAME.git
git push -u origin master

You would need to do something like:

echo "# git push with 2FA and personal access token" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://$USERNAME:$TOKEN@github.com/$USERNAME/$REPONAME.git
git push -u origin master