⚠️ Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.

登录 GitHub

打开 Settings

找到 Developer settings

找到 Personal access tokens

点击 Generate new token

配置 token

设置名字,设置过期时间,选择权限 (默认 repo 就可),最后点击 Generate 生成 token
复制生成的 token (一定要复制保存,因为下次打开就没有了,没有了).

使用 token

在原本的 git 地址前面加上刚才复制的 token@ 就可以了,如下:

1
https://<token>@github.com/<username>/<repo>.git

示例:

1
2
3
4
# 你原本是这么用的:
git clone https://github.com/yourname/repo.git repo
# 现在是这么用
git clone https://ghp_lXdQ40bySDRq0jvDODSQO5NxaKDXDO360Zvq@github.com/yourname/repo.git repo