Authenticate with GitHub using a token

后端 未结 10 544
广开言路
广开言路 2020-11-30 17:09

I am trying to authenticate with GitHub using a personal access token. In the help files at github, it states to use the cURL method to authenticate (https://help.github.com

10条回答
  •  旧巷少年郎
    2020-11-30 17:25

    First, you need to create a personal access token (PAT). This is described here: https://help.github.com/articles/creating-an-access-token-for-command-line-use/

    Laughably, the article tells you how to create it, but gives absolutely no clue what to do with it. After about an hour of trawling documentation and Stack Overflow, I finally found the answer:

    $ git clone https://github.com/user-or-organisation/myrepo.git
    Username: 
    Password: 
    

    I was actually forced to enable two-factor authentication by company policy while I was working remotely and still had local changes, so in fact it was not clone I needed, but push. I read in lots of places that I needed to delete and recreate the remote, but in fact my normal push command worked exactly the same as the clone above, and the remote did not change:

    $ git push https://github.com/user-or-organisation/myrepo.git
    Username: 
    Password: 
    

    (@YMHuang put me on the right track with the documentation link.)

提交回复
热议问题