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