github access tokens

 原创    2019-01-12

github开启Two-factor authentication之后,需要使用Personal access tokens访问。

Two-factor authentication

github未开启两步验证时,可以使用:

git clone https://[email]:[password]@github.com/username/repo.git //Clone with HTTPS

email中@符号需要更换为:%40

开启两步验证,需要使用 access tokens。

生成access tokens

登录 github 后:

Developer settings->Personal access tokens->Generate new token->输入token的名称->Select scopes勾选repo->Generate token.

复制 access tokens 并保存,离开页面之后不再显示。

使用access tokens

git clone https://github.com/username/repo.git
username: your email
Password: your access tokens

提示输入密码时输入 access tokens 即可。

在是mac系统中,access tokens会保存在keychain中,其他系统会保存在~/.git-credentials中。下次再访问时就会自动读取保存的认证信息,达到和Clone with SSH一样的使用效果。

相关文章:

git config 配置
git技巧:gitignore忽略已提交的文件
git瘦身:清除大文件或敏感文件记录

发表留言

您的电子邮箱地址不会被公开,必填项已用*标注。发布的留言可能不会立即公开展示,请耐心等待审核通过。