簡單版的 Github 版控方式,讓新手們能簡單上手,但並不正規。
Git 環境
Ubuntu
如何使用:在該資料夾內打開 Terminal,即可輸入指令
Windows
Download for Windows
如何使用:對該資料夾右鍵,點擊 Git Bash
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
基本操作
1. 設置好個人資料
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
2. 將 repositories 存入本地
3. 如何開始操作
對該 Repositorie 資料夾開啟 Git bash 或 Terminal,即可輸入指令。
使用方式
簡單的流程
- 先有 main 與 dev 兩個分支:
- main:上線給使用者使用的版本
- dev:新功能上傳到此分支做測試
- 步驟:
創建一個功能的分支 -> 完成此功能
-> 將新功能連同分支合併到 dev -> 合併後就刪除該分支(網站上會問你要不要刪掉)
操作示範
-
從 dev 創建新分支,並在此分支撰寫新功能
git switch -c add-login-function
-
每完成一個環節就做紀錄與推送
- 加入所有本地修改
git add .
- 加入本次修改的訊息
git commit -m "Feat: Add input box."
- 上傳到遠端 Repository
git push git push --set-upstream origin add-login-function
(第一次要設置 upstream)
- 之後的每次修改如下
git add .
git commit -m "Feat: Add button."
git push
(已經設置 upstream 就能直接push)
-
完成功能後,就能丟回原來的分支
到 Github 上的 Repository,去建立 Pull Request
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →
接著寫標題,以及敘述本分支做了哪些事情,也能放圖片。
-
之後的每個新功能都按照1->2->3的流程進行
- 注意:
- 請不要寫無用的 git commit ,應按照 Commit 守則。
- 請敘述清楚 Pull Request(PR)。
- 請善用分支操作,否則團隊難以協同。
- 團隊應該要互相 review code,確保一致性、可讀性。
常用指令
1. 本地分支操作
2. 如何推送與取得
比如:git commit -m "Feat: Add input box."
類型 |
說明 |
程式碼改動 |
Feat |
新功能。 |
有 |
Modify |
既有功能需求調整的修改。 |
有 |
Fix |
錯誤修正。 |
有 |
Docs |
更新文件,如 README.md。 |
沒有 |
Style |
程式碼格式調整(formatting)、缺少分號(missing semi colons)等。 |
沒有 |
Refactor |
重構。針對已上線的功能程式碼調整與優化,且不改變記有邏輯。 |
有 |
Test |
測試。新增測試、重構測試等 |
沒有 |
Chore |
更新專案建置設定、更新版本號等瑣事。 |
沒有 |
Revert |
撤銷之前的commit。 revert: type(scope): subject (回覆版本:xxxx) |
有 |
節錄於 Git Commit Message 格式與規範整理
3. 分支合併、與其他使用者互動:Pull Request(PR)
流程:
建立 PR -> 給大家 review 確認沒問題或是利用留言 -> 自己合併或是讓其他使用者合併
主要功能:
- 設置 Reviewers:讓其他人收到 review 程式碼的通知,並且給建議。
- 設置 Development 可以去綁定此 PR 跟那些 Issue 有關係,比如這個 PR 是修復某種 BUG,就可以把該 BUG 的 Issue 連接進來,方便釐清關係。
Image Not Showing
Possible Reasons
- The image was uploaded to a note which you don't have access to
- The note which the image was originally uploaded to has been deleted
Learn More →