These are instructions for setting up git on your Windows machine to authenticate with GitHub when you have 2-factor authentication set up. This authentication should be inherited by any GUI client you are using.
-
Download and install the git command-line client
-
git config --global user.name 'Firstname Lastname' git config --global user.email '[email protected]' -
Turn on the credential helper to cache your credentials (so you only need to do this once):
git config --global credential.helper wincred -
Set up a personal access token for github - I recommend giving it
gist,repo, anduserscope. Make sure you copy the token now as you won't be able to later -
Create test repository in the bcgov org.
-
Clone the repository on the command line:
git clone https://github.com/bcgov/[my-test-repo] -
Make any change you want in your local repository. Eg., make or edit your
README.mdfile. -
Add, commit, and push your changes:
git add README.md git commit -m "Edit README" git push -u origin masterAt this point you'll be asked for your username and password. Enter your username, then in the password prompt paste your Personal Access Token you created in step 3. (Note: in the windows git bash shell, paste with Shift+Insert or right-click -> paste)
-
Now push AGAIN.
git pushYou should NOT be asked for your username and password, instead you should see
Everything up-to-date.Rejoice and close the shell.