上傳本地檔案到GitHub

2021-08-15 02:38:52 字數 1087 閱讀 2801

前段時間將自己的專案通過命令列的方式上傳至github遇到一些問題,也總結了一些經驗,在這裡分享給大家乙個上傳步驟

第一步:建立你的git倉庫

命令列cd到你的專案資料夾裡面,執行git命令建立倉庫

git init
第二步:選擇要新增進倉庫的檔案
git add .
如果想新增指定的檔案,就去掉.就ok了

第三步:選擇要新增進倉庫的檔案

git commit -m "注釋"
第四步:與倉庫與github相關聯

如果沒有遠端倉庫就需要去github進行建立

git remote add origin 這裡接你的https鏈結
git remote add origin
當然,在這裡你可能會遇到fatal:remote origin already exists的error,解決辦法如下

按順序執行如下步驟

git remote rm origin
git remote add origin
第五步:合併github

因為你可能在github上建立儲存庫時勾選了

initialize this repository with a readme(

使用readme初始化此儲存庫)

,這樣就

會導致你本地的倉庫和github上儲存庫產生衝突。

git pull --rebase origin master
第六步:pull(把github上邊的檔案拉取下來)

這一步的操作主要是為了防止出現error:failed to push some refs to 的錯誤

git pull origin master
第七步:上傳檔案
git push -u origin master
執行完以上步驟,你的檔案就上傳成功了。

git 上傳本地檔案到github

git 上傳本地檔案到github 1 git config global user.name your real name 2 git config global user.email you email.address git init git add git commit m test git...

git 上傳本地檔案到github

git 上傳本地檔案到github 1 git config global user.name your real name 2 git config global user.email you email.address git init git add git commit m test git...

git上傳本地檔案到GitHub

檢視分支 git branch 新建分支 git checkout b 切換分支 gitcheckout git刪除遠端倉庫檔案 1 在本地拉取分支 git pull origin hukongtao 你想操作的分支 2 在本地刪除對應的檔案 git rm filename 同時在快取和物理儲存中刪...