一、建立本地仓库:操作环境(终端)
1 | 1.cd到本地项目的文件夹路径下 |
二、添加远程仓库:操作环境(github上)
三、建立连接:操作环境(终端)
1 | git remote add origin git@github.com:DaiYongTao/demo.git |
其中`git@github.com:DaiYongTao/demo.git` 是图3中选择SSH时的地址
四、将本地仓库push到远程仓库:操作环境(终端)
1 | git push -u origin master // 第一次推送master分支上所有的内容 |
五、错误问题解决办法
(很重要!!!注:在做这些步骤的前提是已经将ssh在本地创建好了。亦或者你的ssh已经过期了,你进行上面的最后一个步骤时会报错。所以需要检查ssh状态)
如果出现以下错误:1
2
3
4
5Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
是因为你的ssh过期了,需要重新获取ssh,然后添加到github上去。
相关链接:Github上如何创建ssh