上传本地文件到github仓库

 

第一步:新建仓库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

相关文章
相关标签/搜索