在我的 Mac 机器上,使用 https 的 Git clone 无法工作,出现以下错误:
akshaybandivadekar@Akshays-MacBook-Pro codebase % git clone https://github.com/lodash/lodash.git
Cloning into 'lodash'...
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
但使用 ssh 就可以了
git clone [email protected]:lodash/lodash.git
我参考了此文档来进行 ssh 密钥设置: https://docs.github.com/en/authentication/connecting-to-github-with-ssh/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
答案1
这解决了我的问题
git config --global url."[email protected]:".insteadOf "https://github.com/"