# git 協作練習 ## 前題: * 以 vite-bootstrap5 版練習,適用於專題協作 * [gh-page] 這個分支無法版本控制 協調作法:由指定人選統一執行 npm run deploy * 分支規則設定 `feature/功能、單元、頁面名稱` * commit 規則: `git commit -m "commit內容"` 新增:[add]+新增內容概述… 修改:[update]+變更內容概述… --- ## 2023-8-17 第一次 git 協作練習 ### 專案位址:https://github.com/townyuan/git-training-2023-3 ### ==★ 建議可開啟 souretree 觀察分支情況 ★== ### 1、clone 到本地開發環境 ``` git clone https://github.com/townyuan/git-training-2023-3.git ``` ### 2、各自開分支,新增&修改頁面 ==以下 for 第一次練習(2023-8-17)== | 名稱 | 分支 | 備註 | | :--: | :-- |:-- | | yuan! | feature/index | 修改檔案 | | Tami | feature/about | 修改檔案 | | judy | feature/contact | 修改檔案 | | shcopy| feature/faq | 新增檔案 | ※ 語法提示: > git branch [分支名稱] ### 3、到 GitHub 上發PR 將新增/修改的檔案 push 到分支後,再到 GitHub 上發 PR ※ 語法提示: > git add . > git commit -m "[add] or [update] commit text..." > git push origin [分支名稱] ### 4、code review 利用 git fetch 把遠端檔案同步回本地端,coed review 沒問題的話,做以下兩個動作 - 到 GitHub 上,Merge PR - 本地端 merge orign/main ※ 語法提示: > git fetch origin main > git merge origin/main --- --- ### 另一種合併方式:git rebase 練習 (下次練習) :::warning rebase 有點像移花接木,把同一個 base(基礎) 的分支,複製再貼到往後的時間軸線上,接續在同一個支線上 教學影片:https://gitbook.tw/chapters/branch/merge-with-rebase ::: 情境: main 有兩個分支 feature/dog、feature/cat,分別有 commit 點 ![](https://hackmd.io/_uploads/BJQAQDo32.jpg) --- ### git 常用速查表 ![](https://hackmd.io/_uploads/BJ9G6So22.jpg) 來源:https://cdn.discordapp.com/attachments/1128973772876161067/1141634565190979654/Git_.png