Menu Close
    Start a Project Request quote Reading list Switch to dark mode

    Make “git pull/push/clone” work with two factor authentication

    Today I face an issue when I was trying to push my recent changes on my GITHUB directory.  I was getting an access authentication error even my details were correct.

    Authentication Error

    Then a bit searching a got to know that I am getting this error because of 2FA(two-factor authentication) is enabled in my account which I enabled a few days ago.

    Basically, 2FA provides an extra layer of security used when logging into the account. For more details please refer to the GITHUB TWO FACTOR AUTHENTICATION

    2FA requires user access token instead of the user password while running pull and push operation in GITHUB.

    • Without 2FA
      • $ git clone
        • Username: your_username
        • Password: your_password
    • With 2FA
      • $ git clone
        • Username: your_username
        • Password: your_access_token

    Then first we need to know how to set up access token key on GITHUB account for the command line. Steps are given below,

    • First of all, make sure your email-id should be verified. If not then verify first.
    • Then go to the top right corner of your GITHUB account. Where you will see your profile picture. Click on that picture and then click on setting.

      GITHUB Main Settings

    • Then on the left side menubar, you will see “Developer Setting“. Click on it and then click on “Personal access tokens”

      Developer Setting

      Personal Access Token

    • Then you will see a button “Generate new token“. Click on that button to generate an access token,

      Token Menu

    • Then after giving the access token name select the permission which you would like to give for that token.

      GITHUB Token Name

      Select permissions for access tokens

    • After that click on “Generate Token“. Then you token will appear on the window.

      GITHUB Account Token

    This is how you can create an access token.

    NOTE: Keep your access token secret 

    Now you can use access token as your authentication password for GITHUB pull & push operations.


    We would love the hear your thoughts, suggestions, and questions in the comments below !!



    . . .

    Comments (8)

    Add Your Comment

  • Arun
    How to clone a git repository from commandline with PersonalAccessToken?
  • Iain Sanderson
    I finally found this blog and fix my issue.
    Thank you.
    • Megha Joshi
      Hello Iain,
      Thanks for the feedback, for any further assistance kindly drop us a mail at-


    Excellent. Works perfectly fine. Thank you.
    • Megha Joshi
      Thank you for the feedback.


  • Lucas Andrade
    Awesome tutorial, thank you so much. The pictures really helped me.
    • Megha Joshi
      Hello Lucas,
      Thanks for your valuable feedback and appreciation.


  • Back to Top
    Hire Us!
    Brief us about your requirements and we'll get back to you.
    Woo! Hooy!
    We have just recieved your project brief and our expert will contact you shortly.
    Send Again