在 github 上 clone/push/pull 时遇到 Username for 'https://github.com'

1,497 阅读1分钟

有时候在 git 上 clone、push、pull 代码时会遇到这些提示,应该怎么解决?

Cloning into 'xxx'...
Username for 'https://github.com': 
Password for 'https://xxx@github.com':

remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls for information on currently recommended modes of authentication.

这里要输入的不是github的账号密码,而是一个token

解决方案

Username:输入当前邮箱 Password:输入token

如果没有token那就新创建一个,步骤如下:

第一步

点击右上角头像,选择 setting/设置

第二步

滑到最下面,在左侧选择 Developer setting/开发者设置

第三步

选择 Personal access tokens,下面类型任选一个就行

第四步

填写配置信息,token权限范围、过期时间等,然后 Generate token 生成token即可