
使用 https 的 Git 克隆無法在我的 mac 機器上運行,出現以下錯誤:
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/generate-a-new-ssh-key-and-adding-it-to-the-ssh-agent
答案1
這解決了我的問題
git config --global url."[email protected]:".insteadOf "https://github.com/"