我的Github和Git使用都没有什么问题,也不存在ssh key的问题,但是在fork了别人的仓库,git clone之后,进行修改然后准备git push的时候出现了报错:
ERROR: Permission to XXX.git denied to deploy key fatal: Could not read from remote repository.
最后发现是git clone 时候选择了ssh方式而不是https方式
最后的解决办法是 使用git remote set-url
命令 进行切换。
首先检查一下目前的url:
如果使用git clone
命令时 使用了ssh,
这时,使用
git remote -v
会显示为
origin git@github.com:YourGithubUserName/RepositoryName.git (fetch)
origin git@github.com:YourGithubUserName/RepositoryName.git (push)
进行解决:
1.进行切换:
git remote set-url origin https://github.com/YourGithubUserName/RepositoryName.git
2.检查一下:
git remote -v
如果显示为
origin https://github.com/YourGithubUserName/RepositoryName.git (fetch)
origin https://github.com/YourGithubUserName/RepositoryName.git.git (push)
则切换成功。