git 终端 上传本地项目到github仓库
2016-12-15 10:52
330 查看
第一步:建立本地Git仓库
cd到你的本地项目根目录下,执行git命令
git
init
第二步:将本地项目工作区的所有文件添加到暂存区
git
add .
如果想添加项目中的指定文件,那就把.改为指定文件名即可
第三步:将暂存区的文件提交到本地仓库
git
commit -m ""
冒号里面写注释语句
第四步:在Github上创建自己的repository,创建如图所示
第五步:将本地仓库关联到Github上
git remote add origin https://github.com/CSUDUC/ars
后面的URL地址就是我在第四步时复制的那个https地址
在这一步时如果出现错误:fatal:remote origin already exists
那就先输入 git remote rm origin
再输入 git remote add origin https://github.com/FISHBALL1/DropList 就不会报错了。
第六步:最后一步,将代码由本地仓库上传到Github远程仓库
git push -u origin master
执行完之后如果无错误就上传成功了,需要提示的是这里的master是Github默认的分支,如果你本地的当前分支不是
master,就用git checkout master命令切换到master分支,如果你想用本地当前分支上传代码,则把第六步的命令
里的master切换成你的当前分支名即可。
如果github上建的库里有readme文档,会出现如下错误:
error: failed to push some refs to 'https://github.com/CSUDUC/ars'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
可以通过如下命令进行代码合并【注:pull=fetch+merge]
git pull --rebase origin master
此时再执行语句 git push -u origin master即可完成代码上传到github
上传成功界面
cd到你的本地项目根目录下,执行git命令
git
init
第二步:将本地项目工作区的所有文件添加到暂存区
git
add .
如果想添加项目中的指定文件,那就把.改为指定文件名即可
第三步:将暂存区的文件提交到本地仓库
git
commit -m ""
冒号里面写注释语句
第四步:在Github上创建自己的repository,创建如图所示
第五步:将本地仓库关联到Github上
git remote add origin https://github.com/CSUDUC/ars
后面的URL地址就是我在第四步时复制的那个https地址
在这一步时如果出现错误:fatal:remote origin already exists
那就先输入 git remote rm origin
再输入 git remote add origin https://github.com/FISHBALL1/DropList 就不会报错了。
第六步:最后一步,将代码由本地仓库上传到Github远程仓库
git push -u origin master
执行完之后如果无错误就上传成功了,需要提示的是这里的master是Github默认的分支,如果你本地的当前分支不是
master,就用git checkout master命令切换到master分支,如果你想用本地当前分支上传代码,则把第六步的命令
里的master切换成你的当前分支名即可。
如果github上建的库里有readme文档,会出现如下错误:
error: failed to push some refs to 'https://github.com/CSUDUC/ars'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
可以通过如下命令进行代码合并【注:pull=fetch+merge]
git pull --rebase origin master
此时再执行语句 git push -u origin master即可完成代码上传到github
上传成功界面
相关文章推荐
- 怎么用git bash上传本地项目代码到您的github仓库1
- 如何用git将本地仓库中的项目上传到github
- git建立本地仓库、gitHub上传项目以及git和gitHub的关系
- git上传本地项目到远程github仓库
- windows中使用Git上传本地项目到Github的仓库中
- 如何利用git将本地项目上传到码市、github等远程仓库
- git 将本地项目上传到github
- 使用git和github上传本地项目
- git上传本地Intellij idea 项目到github
- Git本地项目上传 & SourceTree & GitHub 简单使用
- git从本地仓库上传到github
- git上传本地项目到github
- 使用Git命令行上传本地项目到GitHub
- 使用 eclipse+egit 将项目提交至 github ,本地的git仓库:eclipse工作项目目录
- 如何将本地项目上传到git的中间仓库和下载到本地及注意点
- git上传本地项目到github
- 使用Git命令把本地项目上传到Github托管
- 在终端上传本地项目到GitHub
- 使用Git命令把本地项目上传到Github托管
- 教你快速掌握androidstudio使用git上传本地项目到github、版本控制