A Pull Request (PR) is a way to propose changes to a project. Instead of pushing directly to the develop branch, you push your changes to a separate branch and ask your team to review them before merging.
Pull Request(PR)是一種向專案提出修改建議的方式。你不會直接推送到 develop 分支,而是推送到一個獨立的分支,然後請團隊審核後再合併。
Pull Request(PR)是一种向项目提出修改建议的方式。你不会直接推送到 develop 分支,而是推送到一个独立的分支,然后请团队审核后再合并。
Ang Pull Request (PR) ay isang paraan para mag-propose ng mga pagbabago sa isang project. Sa halip na mag-push nang diretso sa develop branch, ipo-push mo ang iyong mga pagbabago sa isang hiwalay na branch at hihilingin sa iyong team na i-review bago i-merge.
Why use Pull Requests? 為什麼要用 Pull Request? 为什么要用 Pull Request? Bakit gumamit ng Pull Request?
Before creating a PR, make sure your branch is ready: 建立 PR 之前,確保你的分支已準備好: 创建 PR 之前,确保你的分支已准备好: Bago gumawa ng PR, siguraduhing handa na ang iyong branch:
1. Make sure all your changes are committed: 1. 確認所有改動都已 commit: 1. 确认所有改动都已 commit: 1. Siguraduhing lahat ng pagbabago ay naka-commit na:
$ git status
On branch feature/my-task
nothing to commit, working tree clean
2. Push your branch to Gitea: 2. 將你的分支推送到 Gitea: 2. 将你的分支推送到 Gitea: 2. I-push ang iyong branch sa Gitea:
$ git push -u origin feature/my-task
3. (Optional) Update your branch with the latest develop to avoid conflicts:
3.(可選)同步最新的 develop 來避免衝突:
3.(可选)同步最新的 develop 来避免冲突:
3. (Opsyonal) I-update ang iyong branch gamit ang pinakabagong develop para maiwasan ang mga conflict:
$ git pull origin develop
$ git push
Open git.datawords.hk and navigate to your repository. 打開 git.datawords.hk,進入你的 repository。 打开 git.datawords.hk,进入你的仓库。 Buksan ang git.datawords.hk at pumunta sa iyong repository.
After pushing your branch, Gitea often shows a prompt to create a PR. You can also create one manually: 推送分支後,Gitea 通常會顯示建立 PR 的提示。你也可以手動建立: 推送分支后,Gitea 通常会显示创建 PR 的提示。你也可以手动创建: Pagkatapos i-push ang iyong branch, madalas magpapakita ang Gitea ng prompt para gumawa ng PR. Maaari mo rin itong gawin nang manu-mano:
Option A: Click the prompt banner that appears after pushing: 方法 A:點擊推送後出現的提示橫幅: 方法 A:点击推送后出现的提示横幅: Option A: I-click ang prompt banner na lalabas pagkatapos mag-push:
Option B: Go to the repository page, click "Pull Requests" in the top menu, then click "New Pull Request". 方法 B:進入 repository 頁面,點擊頂部選單的 「Pull Requests」,再點擊 「New Pull Request」。 方法 B:进入仓库页面,点击顶部菜单的 "Pull Requests",再点击 "New Pull Request"。 Option B: Pumunta sa repository page, i-click ang "Pull Requests" sa top menu, pagkatapos i-click ang "New Pull Request".
Fill in the PR form: 填寫 PR 表單: 填写 PR 表单: Punan ang PR form:
feat: add user login page)
標題:簡短總結你做了什麼(例如 feat: add user login page)
标题:简短总结你做了什么(例如 feat: add user login page)
Title: Maikling buod ng ginawa mo (hal. feat: add user login page)
Click "Submit Pull Request" to create it. 點擊 「Submit Pull Request」 建立 PR。 点击 "Submit Pull Request" 创建 PR。 I-click ang "Submit Pull Request" para gawin ito.
After creating the PR, your teammates will review your changes. Here's how the review process works: 建立 PR 後,你的團隊成員會審核你的改動。以下是審核流程的運作方式: 创建 PR 后,你的团队成员会审核你的改动。以下是审核流程的运作方式: Pagkatapos gumawa ng PR, ire-review ng iyong mga kasamahan ang mga pagbabago mo. Ganito gumagana ang review process:
# Make requested changes, then:
$ git add .
$ git commit -m "fix: address review feedback"
$ git push
Once the PR is approved, it's time to merge your changes into develop.
PR 被批准後,就可以將你的改動合併到 develop 了。
PR 被批准后,就可以将你的改动合并到 develop 了。
Kapag na-approve na ang PR, oras na para i-merge ang iyong mga pagbabago sa develop.
On the PR page, scroll down to find the merge button: 在 PR 頁面向下捲動找到合併按鈕: 在 PR 页面向下滚动找到合并按钮: Sa PR page, mag-scroll pababa para mahanap ang merge button:
Gitea offers several merge strategies. The most common ones are: Gitea 提供幾種合併策略。最常用的有: Gitea 提供几种合并策略。最常用的有: Nag-aalok ang Gitea ng ilang merge strategies. Ang pinakakaraniwan ay:
develop into your branch, resolving conflicts, and pushing again.
如果有合併衝突,Gitea 會要求你先解決才能合併。你可以在本地將 develop 拉取到你的分支、解決衝突後再推送。
如果有合并冲突,Gitea 会要求你先解决才能合并。你可以在本地将 develop 拉取到你的分支、解决冲突后再推送。
Kung may merge conflicts, hihilingin ng Gitea na i-resolve ang mga ito bago mag-merge. Maaari mo itong gawin nang lokal sa pamamagitan ng pag-pull ng develop sa iyong branch, pag-resolve ng conflicts, at muling pag-push.
Merging into certain branches triggers automatic deployment via Gitea Actions: 合併到特定分支會透過 Gitea Actions 自動部署: 合并到特定分支会通过 Gitea Actions 自动部署: Ang pag-merge sa ilang branches ay nagti-trigger ng automatic deployment sa pamamagitan ng Gitea Actions:
When a deployment is triggered, Gitea Actions runs the build automatically. You can check the build status and logs in the Actions tab of your repository. 當觸發部署時,Gitea Actions 會自動執行建置。你可以在 repository 的 Actions 分頁查看建置狀態和日誌。 当触发部署时,Gitea Actions 会自动执行构建。你可以在仓库的 Actions 标签页查看构建状态和日志。 Kapag na-trigger ang deployment, awtomatikong tatakbo ang build sa pamamagitan ng Gitea Actions. Maaari mong i-check ang build status at logs sa Actions tab ng iyong repository.
Go to your repository on Gitea and click "Actions" in the top navigation bar (next to Pull Requests, Packages, etc.): 前往 Gitea 上的 repository,點擊頂部導覽列的 「Actions」(在 Pull Requests、Packages 旁邊): 前往 Gitea 上的仓库,点击顶部导航栏的 "Actions"(在 Pull Requests、Packages 旁边): Pumunta sa iyong repository sa Gitea at i-click ang "Actions" sa top navigation bar (katabi ng Pull Requests, Packages, atbp.):
The Actions page shows a list of all workflow runs. You can filter by workflow name, status, or who triggered the run: Actions 頁面會顯示所有工作流程執行記錄。你可以按工作流程名稱、狀態或觸發者篩選: Actions 页面会显示所有工作流程执行记录。你可以按工作流程名称、状态或触发者筛选: Ang Actions page ay nagpapakita ng listahan ng lahat ng workflow runs. Maaari kang mag-filter ayon sa workflow name, status, o kung sino ang nag-trigger:
↑ The Actions tab shows each workflow run with its status, branch, and who triggered it ↑ Actions 分頁顯示每次工作流程執行的狀態、分支和觸發者 ↑ Actions 标签页显示每次工作流程执行的状态、分支和触发者 ↑ Ipinapakita ng Actions tab ang bawat workflow run kasama ang status, branch, at kung sino ang nag-trigger
Click on any workflow run to open the detail page. Here you can see: 點擊任意一次執行即可打開詳情頁面。你可以看到: 点击任意一次执行即可打开详情页面。你可以看到: I-click ang anumang workflow run para buksan ang detail page. Makikita mo:
↑ The run detail page shows jobs on the left and step-by-step logs on the right. Click a failed step to see the error. ↑ 執行詳情頁面左側顯示任務,右側顯示逐步日誌。點擊失敗的步驟即可查看錯誤。 ↑ 执行详情页面左侧显示任务,右侧显示逐步日志。点击失败的步骤即可查看错误。 ↑ Ang run detail page ay nagpapakita ng jobs sa kaliwa at step-by-step logs sa kanan. I-click ang nabigong step para makita ang error.
If a deployment causes problems, you can roll back by reverting the merge commit. This creates a new commit that undoes the changes, which triggers a fresh deployment of the corrected state. 如果部署導致問題,你可以透過還原(revert)合併 commit 來回滾。這會建立一個新 commit 撤銷改動,從而觸發修正版本的重新部署。 如果部署导致问题,你可以通过还原(revert)合并 commit 来回滚。这会创建一个新 commit 撤销改动,从而触发修正版本的重新部署。 Kung nagdulot ng problema ang deployment, maaari kang mag-rollback sa pamamagitan ng pag-revert ng merge commit. Gagawa ito ng bagong commit na nag-a-undo ng mga pagbabago, na magti-trigger ng bagong deployment ng naayos na estado.
On Gitea, go to the merged PR page. The merge commit hash is shown at the bottom of the PR conversation, in the merge message (e.g. "merged commit abc1234 into master"). You can also find it in the branch's commit history. 在 Gitea 上進入已合併的 PR 頁面。合併 commit 的 hash 會顯示在 PR 對話底部的合併訊息中(例如 「merged commit abc1234 into master」)。你也可以在分支的 commit 歷史中找到。 在 Gitea 上进入已合并的 PR 页面。合并 commit 的 hash 会显示在 PR 对话底部的合并消息中(例如 "merged commit abc1234 into master")。你也可以在分支的 commit 历史中找到。 Sa Gitea, pumunta sa merged PR page. Ang merge commit hash ay makikita sa ibaba ng PR conversation, sa merge message (hal. "merged commit abc1234 into master"). Mahahanap mo rin ito sa commit history ng branch.
# Example: rollback on master (production)
$ git checkout master
$ git pull
$ git revert -m 1 abc1234
$ git push
# Example: rollback on staging
$ git checkout staging
$ git pull
$ git revert -m 1 abc1234
$ git push
-m 1 mean?
-m 1 是什麼意思?
-m 1 是什么意思?
Ano ang ibig sabihin ng -m 1?
A merge commit has two parents. -m 1 tells Git to keep the first parent (the branch you merged into, e.g. master) and undo the second parent (the feature branch changes). This is always what you want when reverting a merge.
合併 commit 有兩個父 commit。-m 1 告訴 Git 保留第一個父 commit(你合併進去的分支,例如 master),撤銷第二個父 commit(功能分支的改動)。還原合併時一律使用這個參數。
合并 commit 有两个父 commit。-m 1 告诉 Git 保留第一个父 commit(你合并进去的分支,例如 master),撤销第二个父 commit(功能分支的改动)。还原合并时一律使用这个参数。
Ang merge commit ay may dalawang parents. Sinasabi ng -m 1 sa Git na panatilihin ang unang parent (ang branch na pinag-merge-an, hal. master) at i-undo ang pangalawang parent (ang feature branch changes). Ito ang laging kailangan kapag nagri-revert ng merge.
After pushing the revert commit, Gitea Actions will automatically build and deploy the corrected version. Check the Actions tab to confirm the deployment succeeded. 推送 revert commit 後,Gitea Actions 會自動建置並部署修正版本。查看 Actions 分頁確認部署成功。 推送 revert commit 后,Gitea Actions 会自动构建并部署修正版本。查看 Actions 标签页确认部署成功。 Pagkatapos i-push ang revert commit, awtomatikong magbi-build at magde-deploy ang Gitea Actions ng naayos na version. I-check ang Actions tab para i-confirm na nagtagumpay ang deployment.
After merging, clean up by deleting the feature branch: 合併後,刪除功能分支進行清理: 合并后,删除功能分支进行清理: Pagkatapos mag-merge, mag-clean up sa pamamagitan ng pag-delete ng feature branch:
On Gitea: After merging, Gitea shows a "Delete Branch" button. Click it to remove the remote branch. 在 Gitea 上:合併後,Gitea 會顯示 「Delete Branch」 按鈕。點擊即可刪除遠端分支。 在 Gitea 上:合并后,Gitea 会显示 "Delete Branch" 按钮。点击即可删除远端分支。 Sa Gitea: Pagkatapos mag-merge, magpapakita ang Gitea ng "Delete Branch" button. I-click ito para alisin ang remote branch.
On your computer: Switch back to develop, pull the merged changes, and delete the local branch:
在你的電腦上:切回 develop,拉取已合併的改動,並刪除本地分支:
在你的电脑上:切回 develop,拉取已合并的改动,并删除本地分支:
Sa iyong computer: Bumalik sa develop, i-pull ang mga naka-merge na pagbabago, at i-delete ang local branch:
$ git checkout develop
$ git pull
$ git branch -d feature/my-task
-d flag only deletes the branch if it has been merged. This is a safe operation. If you see an error, it means the branch hasn't been merged yet.
-d 參數只會刪除已合併的分支,這是安全的操作。如果你看到錯誤,表示該分支尚未合併。
-d 参数只会删除已合并的分支,这是安全的操作。如果你看到错误,表示该分支尚未合并。
Ang -d flag ay nagde-delete lang ng branch kung ito ay naka-merge na. Ito ay ligtas na operasyon. Kung may error, ibig sabihin hindi pa naka-merge ang branch.
Create a branch → make changes → push → create PR → get reviewed → merge → clean up. Repeat for every task! 建立分支 → 修改 → 推送 → 建立 PR → 審核 → 合併 → 清理。每個任務重複這個流程! 创建分支 → 修改 → 推送 → 创建 PR → 审核 → 合并 → 清理。每个任务重复这个流程! Gumawa ng branch → gumawa ng pagbabago → push → gumawa ng PR → ma-review → merge → linisin. Ulitin para sa bawat task!