# Open Source 開發流程簡易整理 ### 1.尋找適合的 Open Source 專案 ### 2. Fork 到自己的 Repository 點選 GitHub/GitLab 的 Fork 按鈕,把原始倉庫 (upstream) 複製到自己的帳號,變成自己的 repo (origin)。 ### 3. Clone 專案到本地端 - 複製自己 fork 的 repo 到本地環境: ``` git clone https://github.com/your-username/project-name.git cd project-name ``` - 設定 upstream(指向原始專案): - origin 指向你的 fork。 - upstream 指向原始 repo(官方專案)。 ``` git remote add upstream https://github.com/original-author/project-name.git ``` - 確認 remote 設定: ``` git remote -v ``` ### 4. 建立新分支開發 - 同步 upstream 以確保最新代碼: ``` git checkout main git pull upstream main # 或 git fetch upstream && git merge upstream/main ``` - 開新分支進行開發: ``` git checkout -b feature-branch ``` ### 5. 開發與測試 - 修改代碼,並確保符合貢獻規範(Lint、測試)。 - 執行測試 ### 6. [Commit 代碼](https://www.conventionalcommits.org/zh-hans/v1.0.0/) - 檢查修改內容: ``` git status git diff ``` - 提交更改: ``` git add . git commit -m "Fix: 修正錯誤 #123" ``` ### 7. 推送到自己的 Fork(origin) ``` git push origin feature-branch ``` ### 8. 建立 Pull Request(PR) - 前往 GitHub,你的 fork 會提示 「Compare & Pull Request」。 - 填寫 PR 資訊: - 標題(Title):清楚描述修復或新增的功能。 - 描述(Description): - 關聯的 Issue (Fixes #123) - 變更內容 - 測試方式 - 等待 Maintainer Review: - 他們可能會要求修改(Request Changes)。 - 可能需要進行 rebase 或 squash commit。 ### 9. PR 被合併 - Maintainer 合併 PR: - 如果符合規範,Maintainer 會 Merge PR,變更正式進入 upstream/main。 - 可能會被 Squash 成單一 commit。 - 刪除本地和遠端分支(清理): ``` git branch -d feature-branch git push origin --delete feature-branch ``` ### 10. 同步 upstream 最新狀態 確保你的 main 分支是最新的: ``` git checkout main git pull upstream main git push origin main ``` # 完整流程圖  ```mermaid= graph TD; A[找到 Open Source 專案] -->|Fork| B[自己的 GitHub repo] B -->|Clone| C[下載到本地] C -->|設定 upstream| D[關聯原始專案] D -->|開新分支| E[開發與測試] E -->|Commit 變更| F[推送到自己的 repo] F -->|發送 PR| G[Maintainer Review] G -->|合併 PR| H[變更進入 upstream] H -->|同步最新代碼| I[刪除舊分支] ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up