github上传项目方法:git
在你的电脑上装好gitgithub
Git Bash Hereweb
本地Git仓库和远程仓库的建立及关联大体流程是:spa
1.初始化这个本地的文件夹为一个Git
能够管理的仓库code
git init
注意:Git会自动为咱们建立惟一一个master
分支
咱们可以发如今当前目录下多了一个.git
的目录,这个目录是Git来跟踪管理版本库的,千万不要手动修改这个目录里面的文件,否则改乱了,就把Git仓库给破坏了。blog
2.将本地的仓库和远程的仓库进行关联rem
git remote add origin git@github.com:littleredhatli/webPratice.git
git@github.com:littleredhatli/webPratice.git是咱们远程仓库的路径(webPratice是远程版本库的名字)it
3.新建文件io
touch index
4.将新建的main.m文件添加到仓库(这样git就会追踪
这个文件)ast
git add index
5.把文件提交到仓库
git commit -m "对文件的评注"
6.把本地库的内容推送到远程
git push -u origin master
注意:咱们第一次push
的时候,加上-u
参数,Git就会把本地的master分支和远程的master分支进行关联起来,咱们之后的push
操做就再也不须要加上-u
参数了
假如某天咱们又对mian.m文件进行了修改
git status
查看状态
文件修改
添加到暂存区
git add index
git commit -m "对文件的评注"
git push
github上传(git push)时出现error: src refspec master does not match any
引发该错误的缘由是,目录中没有文件,空目录是不能提交上去的
解决办法
touch README
git add README
git commit -m "评注"
git push origin master
若是在github的remote上已经有了文件,会出现错误。此时应当先pull一下,即:
git pull origin master
而后再进行:
git push origin master