Quantcast
Channel: Push to GitHub Repository without Personal Access Token when 2FA is enabled - Stack Overflow
Viewing all articles
Browse latest Browse all 4

Answer by Natthan Lee for Push to GitHub Repository without Personal Access Token when 2FA is enabled

$
0
0

Building upon Samir's answer, one way to connect to GitHub without typing in the access token every time is to change your local repository's configuration to include your access token in the GitHub URL:

git remote set-url origin https://your_username:your_access_token@github.com/username/repo_name.git

However, when your access token expires, you would have to regenerate it or create a new access token, then re-configure your local repository's GitHub URL to include the updated access token.

Another way, as mentioned in Ferrybig's answer, would be to change your local repository's configuration to connect to GitHub with SSH instead of HTTPS:

git remote set-url origin git@github.com:username/repo_name.git

In order to use SSH, you need to have already created an SSH key and added it to your GitHub account. Find more information at:https://docs.github.com/en/authentication/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images