第一步:新建倉庫html
給倉庫一個名字,備註java
獲得倉庫地址:git
https://github.com/Lucasli2018/java-1-mybatis.git
第二步:進入要上傳的文件夾,初始化上傳文件夾倉庫github
經過git init新建本身的本地倉庫mybatis
git init
第三步:添加全部文件到githtm
經過git add . 把文件添加到暫存區,不要忘記後面的小數點blog
經過git commit -m "first commit",將文件提交到倉庫,引號內爲提交說明rem
git add . git commit -m "first commit"
注意:小數點表示全部文件,也能夠指定文件git add 文件夾名it
第四步:鏈接到guthub倉庫ast
經過 git remote add origin 你的遠程地址來關聯到遠程倉庫
git remote add origin https://github.com/Lucasli2018/********.git
若是不是第一次上傳,可能會提示一下信息:
fatal: 遠程 origin 已經存在。
這時只須要將遠程配置刪除,從新添加便可;
git remote rm origin git remote add origin https://github.com/Lucasli2018/*******.git
第五步:輸入「git push -u origin master」,上傳項目到Github,將本地庫的內容推送到遠程
這裏會要求輸入Github的帳號密碼,按要求輸入就能夠。
git push -u origin master
若是提示錯誤:
error: 沒法推送一些引用到 'https://github.com/Lucasli2018/*********.git'
更新被拒絕,由於遠程倉庫包含您本地尚不存在的提交。這一般是由於另外一個倉庫已向該引用進行了推送。再次推送前,您可能須要先整合遠程變動
則能夠嘗試強行上傳:
git push -u origin +master
錯誤提示
$ git push -u origin master error: src refspec master does not match any. error: failed to push some refs to 'https://github.com/Lucasli2018/java-1-mybatis.git'
緣由:
本地倉庫爲空
解決:先commit本地倉庫文件
git commit -m "first commit"
到GitHub上的遠程倉庫進行刷新便可看到咱們上傳的項目
ok
參考:
https://www.cnblogs.com/roadofstudy/p/7660583.html
https://www.jianshu.com/p/3aca836b932e