41

We like TortoiseGit, and want to take advantage of GitHub's 2-Factor Authentication...but the two don't seem to want to work together.

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
Return_Of_The_Archons
  • 1,731
  • 3
  • 20
  • 26
  • The way this is usually handled is that a special app-specific password is generated, so that the app can still access your account, even if it's protected by 2-Factor Auth. Google does this, for example. I'm not sure if GitHub provides this though, I didn't see anything about it in their [2-Factor Auth documentation](https://help.github.com/categories/84/articles). –  Feb 19 '14 at 21:14

6 Answers6

39

To compliment Cupcake's answer, use the Personal Access token feature within GitHub.com while using TortoiseGit:

  1. Set up 2-step auth.

  2. Set up a personal access token - taking note of the generated token (use the Copy to clipboard button next to the generated token).

  3. Set TortoiseGit to remember your password as detailed here.

  4. Now perform a pull operation on GitHub.com, enter your username, but instead of using your normal password, use the token that was generated in step #2.

  5. Perform another pull operation on GitHub.com to ensure the token is remembered.

Community
  • 1
  • 1
Roadkillnz
  • 773
  • 1
  • 6
  • 14
  • 7
    Not sure how this question wasn't accepted. The accepted answer is essentially saying "I'm not sure, try it" and linking to a blog page that the OP most likely read (which prompted the question) – Rob Oct 15 '15 at 02:10
20

The GitHub blog post about 2-Factor Authentication mentions that you can generate a "personal access token", that can be used in place of a password when 2-Factor Auth is enabled:

enter image description here

I'm not sure if it will actually work with TortoiseGit, but maybe you can give it a try? You can generate an access token at the Authorized applications settings page:

enter image description here

10

Once you create a Personal Access Token in github (see: https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token), go to your TortoiseGit settings for your repository, then go to the local config like so:

enter image description here

After that, edit the URL to the repository, in the format of github username:access_token@rest/of/the/url.git, like so:

enter image description here

Worked for me. Was able to push code with no problems.

Richard
  • 1,912
  • 20
  • 28
3

In case someone has the same problem - using access tokens with TortoiseGit works in general, though for some reason I couldn't force it to use normal authentication prompt, so I had to do git clone https://ghusername:accesstoken@github.com/repo.git

Pawel Gorczynski
  • 1,227
  • 1
  • 15
  • 17
1

This seems to be around for a while and thanks to "Pawel Gorczynski's" answer above I managed to get this to work.

In a specific repository open the '~/repo/.git/config' file and create a line as follows:

[credential "https://GHUserName:GHPersonalAccessToken@github.com/GHUserName/GHRepository"]

GHUserName = Your user name on GitHub not your email.
GHPersonalAccessToken = The entire token string generated at https://github.com/settings/tokens
GHRepository = Name of the repository this access token was made for, note '.git' has been excluded.

You can find or create the config file within '~/repo/.git/config' the config file has no extension and should already exist.

0

You will have to generate access token to pull/push code in Github having two factor authentication using tortoise . Use this token as password.

Here are the additional steps –

https://help.github.com/articles/creating-an-access-token-for-command-line-use/

https://github.com/settings/tokens

Guri
  • 19
  • 3
  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page change – Divyang Desai Dec 01 '16 at 12:26