天天看點

git上傳代碼

第一步:建立項目

1.本地:建立一個檔案——

git init

2.登入GitHub——建立一個倉庫——克隆

git上傳代碼
git上傳代碼
git上傳代碼
git上傳代碼

第二步:在進入檔案夾,随便添加一些.css或.js檔案之類的, 然後執行

git add .

把檔案添加到本地緩存區, 檢視狀态

git status

第三步:送出代碼

git commit -m "submit"

雙引号部分填備注, 怎麼寫都可以

第四步:使用嗎指令

git remote add origin "倉庫位址"

關聯遠端倉庫(一定要仔細看)

我的倉庫位址是:

https://github.com/styleLfie/vue-ui.git

本地config裡面的host

git上傳代碼

關聯遠端倉庫的正确指令:

git remote add origin [email protected]styleLife.github.com:styleLfie/vue-ui.git
[email protected]相當于代替了https://github.com/ 
           

如果這一步已經成功, 其實整個配置已經完成了96%左右

第五步:推送代碼到遠端倉庫

git push origin myFile

(myFile是我建立的分支)

建立分支的指令

git checkout -b myFile

如果推送出現下圖的錯誤

git上傳代碼

解決辦法:執行指令

git remote rm origin

再次執行

git remote add origin [email protected]:styleLfie/vue-ui.git

git push origin myFile

出現如下的結果,恭喜你已經成功了,後面怎麼撸都随意

git上傳代碼