本篇主要参考博文:https://blog.csdn.net/IT_faquir/article/details/52516214git
你要先完成上一篇的操做,即将代码上传到本地仓库中,才能上传到github服务器上,使用命令git commit -m "Name"将代码上传到本地中github
在网页端建立一个Repositorybash
输入仓库的名称,确认建立仓库服务器
在你想上传代码的文件夹中,鼠标右键点击git bash here进入git的界面。学习
如今是关键的步骤了:即要把你本地仓库和你的远程仓库进行链接,这样git才知道你要上传到哪个仓库中。ui
输入命令:.net
git remote add origin "刚刚建立的代码仓库网址"blog
网址格式——git@github.com: + 用户名/ 远程仓库名rem
若是在输入这条命令后出现:error:failed to push som refs to.......it
则先输入git remote rm origin 命令在输入刚刚的指令
5.Push到远程仓库中
使用命令:git push -u origin master (-u通常是第一次上传时使用,后面能够不用-u)
在执行git push origin master时,报错:
error:failed to push som refs to.......
则执行如下语句:
git pull origin master
先把远程服务器github上面的文件拉下来,再push 上去。
这是通常是在工程中有readme那文件,要先pull仓库才能够用
则执行如下语句:
git pull origin master
先把远程服务器github上面的文件拉下来,再push 上去。
大工告成,上传成功
推荐一本入门github贼好的书籍:《github入门与实践》,github入门经典
下载https://download.csdn.net/download/qq_38376586/10552356
欢迎关注本人的公众号,一块儿学习~