如何用命令將本地項(xiàng)目上傳到git
1纸巷、(先進(jìn)入項(xiàng)目文件夾)通過(guò)命令 git init 把這個(gè)目錄變成git可以管理的倉(cāng)庫(kù)
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">git init</pre>
2惶楼、把文件添加到版本庫(kù)中公浪,使用命令 git add .添加到暫存區(qū)里面去举瑰,不要忘記后面的小數(shù)點(diǎn)“.”,意為添加文件夾下的所有文件
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">git add .</pre>
3、用命令 git commit告訴Git琅摩,把文件提交到倉(cāng)庫(kù)厚者。引號(hào)內(nèi)為提交說(shuō)明
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">git commit -m 'first commit'</pre>
4、關(guān)聯(lián)到遠(yuǎn)程庫(kù)
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">git remote add origin 你的遠(yuǎn)程庫(kù)地址</pre>
如:
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">git remote add origin https://github.com/githubusername/demo.git</pre>
5迫吐、獲取遠(yuǎn)程庫(kù)與本地同步合并(如果遠(yuǎn)程庫(kù)不為空必須做這一步,否則后面的提交會(huì)失斦送)
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">git pull --rebase origin master</pre>
6志膀、把本地庫(kù)的內(nèi)容推送到遠(yuǎn)程,使用 git push命令鳖擒,實(shí)際上是把當(dāng)前分支master推送到遠(yuǎn)程溉浙。執(zhí)行此命令后會(huì)要求輸入用戶名、密碼蒋荚,驗(yàn)證通過(guò)后即開(kāi)始上傳戳稽。
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">git push -u origin master</pre>
*、狀態(tài)查詢命令
<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; overflow-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">git status</pre>
備:詳細(xì)請(qǐng)參考 http://www.cnblogs.com/tugenhua0707/p/4050072.html