Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push remote commits to github with two-factor authentication enabled

Is there a way at this moment to push local commits to remote GitHub repository that has two-factor authentication enabled ?.
Without having to disable/enable 2-factor authentication each time we want to push local commits.

Thanks.

like image 840
ismnoiet Avatar asked Jun 23 '16 10:06

ismnoiet


2 Answers

If you prefer HTTPS, you can create a personal access token: https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/

You can create a personal access token and use it in place of a password when performing Git operations over HTTPS with Git on the command line or the API.

Basically, you can find "Personal Access Tokens" in your profile settings. For usage by the git command line tool, you probably want to give your new token access to all of the "repo" permissions, and maybe the "repo_hook" permissions (I don't use hooks, so IDK if this is something the clone needs to access).

Once you've generated the token, copy it to your clipboard, then use it IN PLACE OF your password next time git prompts you for credentials.

like image 171
thelr Avatar answered Oct 18 '22 15:10

thelr


If you use the ssh URL (the one that starts [email protected]) and public key authentication with an ssh key then you don't need to disable 2FA each time you push.

like image 33
philnash Avatar answered Oct 18 '22 15:10

philnash