These are instructions for setting up git to authenticate with GitHub when you have 2-factor authentication set up. This authentication should be inherited by any GUI client you are using. These are intentionally brief instructions, with links to more detail in the appropriate places.
Download and install the git command-line client (if required).
Open the git bash window and introduce yourself to git (if required):
git config --global user.name 'Firstname Lastname' git config --global user.email 'firstname.lastname@example.org'
Turn on the credential helper to cache your credentials (so you only need to do this once):
a. Windows (more detailed instructions here):
git config --global credential.helper wincred
b. Mac (more detailed instructions here):
git config --global credential.helper osxkeychain
Set up a personal access token for accessing GitHub repositories - I recommend giving it
userscope. Make sure you copy the token now as you won't be able to later
Create a test repository in the bcgov organization.
Clone the repository on the command line (terminal/git bash window):
git clone https://github.com/bcgov/[my-test-repo]
Make any change you want in your local repository. Eg., make or edit your
Add, commit, and push your changes:
git add README.md git commit -m "Edit README" git push -u origin master
At 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.
You should NOT be asked for your username and password, instead you should see
Rejoice and close the shell. If your test repository isn't important, you can delete it from the bcgov GitHub account.