川普发动贸易战之后就没有动过 github 账号, 今天新建一个 repo 遇到问题,记录一下.
环境: MacBookPro
1. git push LibreSSL
➜ foodtrucks-api git:(master) git push
fatal: unable to access 'https://github.com/<username>/foodtrucks-api.git/': LibreSSL SSL_read: error:02FFF03C:system library:func(4095):Operation timed out, errno 60
# resovled
➜ foodtrucks-api git:(master) git config --global http.sslBackend "openssl"
2. git push - Support password authentication was removed on August 13, 2021.
不再支持密码认证
➜ foodtrucks-api git:(master) git push
Username for 'https://github.com': {your username}
Password for 'https://{username}@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.
fatal: Authentication failed for 'https://github.com/{username}/foodtrucks-api.git/'
github: Personal Access Token
on your github profile: Setting -> Developer settings -> Personal access tokens -> Generate new token (I choosen classic) -> set the expire date and so on -> generate
步骤:
1. 进入Setting
2. 拉到最后的Developer settings
3. 点击 Personal access tokens
4. 生成token :Generate new token
5. 设置名字、token时长(最后一个选项是永不过期),最后生成即可
6. 复制好token,最好保存好
7. 回到git进行设置
Run on local:
// <your_token>:刚刚生成的token
// <REPO>:要访问的仓库名称,当前仓库的名称
git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git
// <your_token>:刚刚生成的token
// <REPO>:要访问的仓库名称,当前仓库的名称
git remote set-url origin https://<your_token>@github.com/<USERNAME>/<REPO>.git
git push
Resolved!!!