当 git 执行 git push( origin origin/master)后出现错误提示:
git push origin origin/master
Password for ‘https://ghp_354NA4HPtLEWTqloCdTmuEtVIvjA72tO2xnuDR@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 不再支持密码 push 代码,需要配置密钥来实现。并给出了的相应的链接。
1.将本地 id_rsa.pub 拷贝到 github 的 SSH keys 中.(一般在根目录.ssh下面)
打开 github,点击右上角头像,弹出列表,点击“Settings”,点击左侧栏目上的“SSH and GPG keys”,再点击“New SSH Key”,将本地~/.ssh/id_rsa.pub中的内容复制进去。
2.修改本地 git 的remote url
在代码仓库复制ssh地址,然后在本地执行:
git remote set-url origin ssh地址