Using GitHub After Enabling Two-Factor Authentication

If you’ve activated Two-Factor authentication for your GitHub account, you will discover your GitHub account password will become obsolete when performing Git operations that requires account authentication (such as push, fetch, pull) using HTTPS.

A personal access token instead of an account password is what is required to interact with GitHub via https.

Creating a GitHub Personal Access Token

Firstly, log in to your GitHub account, navigate to your ‘profile settings’ and click the Personal access tokens navigation link. Alternatively, use access the page via https://github.com/settings/tokens.

Click on the Generate new token button.

Initiate access token generation

Enter a description for the token and select scopes for the token.

Generate GitHub access token

The default scope selections are basically enough unless you have other plans for the token.

Note: The generated access token is only shown to you once thus, you should save the token to a safe and retrievable location.

You can always generate a new access token if the previous one was forgotten or lost.

The access token is inarguably difficult to remember unlike a password due to it randomness and length hence having enter it when a password is requested can be very annoying.

Configuring Git to Remember Your Credentials

To stop git from continually requesting your username and password, run the command below.

git config credential.helper store

Subsequently, when you enter your username and password, they will be stored in plain text to .git-credentials file at %HomePath%.

Say you reset your access token and wish to delete the previous credential stored by Git, navigate to your %HOMEPATH% (which is C:\Users\{username} in Windows or \Users\{username} in Linux/MAC) and delete the .git-credentials file and you will be prompted to re-enter your credentials which will subsequently be store by Git.

Alternatively, open the .git-credential file and update the access token.

If you use the program Windows Credential Store for Git, it uses the Windows Credential Store to hold your credentials.

To delete your previously saved credentials, search for ‘credential manager’ and open or navigate to Windows control panel \ User Accounts and Family Safety \ User accounts \ Mange your credentials.

Click the Windows credentials tab and edit the git:https://github.com section with your new/current access token.

Windows credentials manager

La Fin.

Don’t miss out!
Subscribe to My Newsletter
Invalid email address