create react app 專案 git push 推不上 remote repo


Posted by mijouhsieh on 2023-09-06

create react app 專案建立專案資料夾時,會自動生成一些資料夾和檔案。

遇到問題:

!!其中包含自動生成的 .git檔案 => 會影響git push 推上GitHub,本地端(source tree沒問題)
create-react-app-gitPush-Fail20230906

嘗試過

git pull <主機名稱> <branch>git push 一樣推不上去

stack overflow 類似問題

GitHub: repository not pushing the folder created with create-react-app
create-react-app-resolution20230906.png

步驟

  1. 刪掉 GitHub上的repo
  2. 刪掉 專案資料夾內的.git 資料夾
  3. 新建 GitHub上的repo
  4. Git Bash 終端機操作:
  5. 進入專案資料夾 cd <資料夾名稱>
  6. 專案資料夾初始化 git init (會新增.git 資料夾)
  7. 加入主機 git remote add origin <GitHub repo url>
  8. 查看已設定好的主機 git remote -v
  9. 查看遠端儲存庫 git remote
  10. GitHub 把master重新命名叫main git branch -M main
  11. Sourcetree
    • Add a repository
    • commit
  12. GitBash操作
    git push -u <主機名稱> main
    create-react-app-gitPush-ok20230906.png
  13. 重新整理 GitHub 頁面,可見專案上傳成功
    create-react-app-GITPUSH-DONE20230906.png

#.git #git push fail







Related Posts

Covariance and Contravariance in Generics

Covariance and Contravariance in Generics

【THM Walkthrough】Exploiting Active Directory (2)

【THM Walkthrough】Exploiting Active Directory (2)

滲透測試基本技術 第三章 (003)

滲透測試基本技術 第三章 (003)


Comments