先关联上远程的GitHub仓库,执行以下git 命令:

git remote rm origin
git remote add origin git@github.com:Eric-seven/sample.git
git push origin master

命令截图

发现在homestead虚拟机中报以下错误:
*Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.*
报错截图

先确保运行在你本机的虚拟机中的SSH Key 相关文件已经从本地电脑同步复制到对应的家目录下的.ssh文件夹中了。
然后将虚拟机中的SSH Key 添加到ssh-agent 中:

eval $(ssh-agent -s)
ssh-add ~/.ssh/id_rsa

命令截图

然后将本地主机中id_rsa.pub 公钥中的内容复制出来。
再到GitHub中添加一个新的 SSH Key
操作演示

完成以上操作,再重新执行:

git push origin master

运行结果截图
successfully!

参考链接:
github 上的参考
代码截图

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐