OS: Mac Mojave
我有一个个人GitHub帐户,我也有贡献,还有其他一些公司帐户。
在我的私人帐户上,我创建了一个私人存储库,我想做的是将本地磁盘上的一些源代码检查到该存储库中。
在Mac终端上,我确保我位于要检入空私人存储库的目录中,然后执行以下操作:
git init
git add .
git commit -m "checking existing files into my private repo"
然后我去了我的私人仓库,并复制了网址,例如:
https://github.com/myaccount/myPrivateRepo
然后我执行以下操作:
git remote add origin https://github.com/myaccount/myPrivateRepo
然后执行:
git remote -v
并得到以下答复:
origin https://github.com/myaccount/myPrivateRepo (fetch)
origin https://github.com/myaccount/myPrivateRepo (push)
我认为这意味着:一切都可以确认
然后我尝试使用:
git push -u origin master
哪个给了我以下错误消息:
remote: Repository not found.
fatal: repository 'https://github.com/myaccount/myPrivateRepo/' not found
我确实将遥控器更改为:
git remote add origin git@github.com:myaccount/myPrivateRepo.git
当我尝试推动时,出现以下错误:
The authenticity of host 'github.com (192.30.255.113)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.255.113' (RSA) to the list of known hosts.
git@github.com: Permission denied (publickey).
致命:无法从远程存储库读取。
Please make sure you have the correct access rights and the repository exists.
答案 0 :(得分:1)
您添加的遥控器应采用以下形式:
git@github.com:myaccount/myPrivateRepo.git
还要设置您的git电子邮件地址,使其与github帐户的电子邮件地址匹配:
git config user.email "you@example.com"
git config user.name "Full Name"
您还可以通过编辑.git/config
文件来编辑它们。
最后,确保正确设置了SSH公钥:
https://github.com/settings/keys
您的公钥应位于cat ~/.ssh/id_rsa.pub
中。您可以使用以下命令进行打印:
cat ~/.ssh/id_rsa.pub
如果您还没有SSH公钥,请遵循以下指南:
https://help.github.com/en/articles/connecting-to-github-with-ssh