Git 路線圖Git Roadmap單元 08Unit 08
團隊協作Team collaboration

GitHub 協作Collaborate on GitHub

UNIT 08 · PULL REQUEST

GitHub 協作Collaborate on GitHub

從推送 feature branch、開 Pull Request、review 到 merge,走完團隊流程。Follow the team workflow from pushing a feature branch to opening, reviewing, and merging a Pull Request.

預計時間Estimated time
25–30 分鐘25–30 minutes
單元類型Unit format
教材+模擬器Lesson + simulator
需要先會Prerequisite
完成 remote 與 mergeComplete remote and merge practice

Pull Request 是討論與檢查的入口

Pull Request(PR)不是 Git 指令,而是 GitHub 上請團隊「把這條 branch 的變更合進目標 branch」的協作流程。

一般順序是:推送 feature branch → 建立 PR → 閱讀 diff → 自動檢查 → reviewer 留言 → 追加修正 commit → 通過 review → merge。

PR merge 後,GitHub 上的 main 已前進,但你的本機 main 不會自動更新。回到本機後仍要:

git switch main
git pull
git branch -d feature/login

Review 的目的不是挑錯字,而是共同確認需求、可讀性、風險與日後維護成本。小而單一目的的 PR 通常比較容易審查。

A Pull Request is the doorway to discussion and checks

A Pull Request (PR) is not a Git command. It is a GitHub collaboration flow that asks the team to merge one branch's changes into a target branch.

The usual order is: push the feature branch → open a PR → read the diff → run automatic checks → receive review comments → add fix commits → pass review → merge.

After the PR merges, GitHub's main has moved, but your local main does not update automatically. Back on your computer, run:

git switch main
git pull
git branch -d feature/login

Review is not about hunting typos. It is a shared check of requirements, readability, risk, and future maintenance cost. Small, single-purpose PRs are usually easier to review.

GITHUB FLOW

Pull Request 六個階段

這是流程示意,不會使用你的 GitHub 帳號,也不會建立真實 PR。

本機 Git

推送 feature branch

feature/login → c4

執行 git push -u origin feature/login,讓 GitHub 看得到支線。

1 / 6

INTERACTIVE LAB

用 remote 模擬器複習推送與同步

輸入指令後,Terminal、四個區域與 Git 樹會從同一份虛擬狀態同步更新。

A

WORKING DIRECTORY

正在編輯的檔案

  • README.md已提交
  • app.js已提交
  • nav.js已提交
B

STAGING AREA

下一版準備內容

  • Staging Area 是空的
C

LOCAL REPOSITORY

電腦裡的版本

HEAD
→ main
目前 commit
c2
commit 數
2
D

REMOTE REPOSITORY

GitHub 示意狀態

origin
尚未設定
遠端 branch
沒有 commit
網路連線
僅記憶體模擬

教學 Terminal

不會執行真實 Git 或 shell

教學模擬器已就緒。這裡不會執行真實 Git 或讀寫你的檔案。

點一下填入:

VIRTUAL FILES

虛擬檔案編輯器

更多情境工具

LIVE GIT TREE

commit 與 branch

HEAD → main
  1. c2
    HEAD → main
    加入導覽列parent:c1
  2. c1
    建立專案parent:無(第一個 commit)

CHECKPOINT

離開前,確認你能用自己的話說明Before you leave, explain it in your own words

  1. 這些指令改變 Git 的哪一個區域?
  2. Git 樹上的 branch 與 HEAD 移到哪裡?
  3. 失敗時 repository 是否保持原狀?
  4. 真實專案操作前,應先查看什麼?
  1. Which Git area does this command change?
  2. Where do the branch and HEAD move in the Git tree?
  3. Does the repository stay unchanged when the command fails?
  4. What should you check before operating on a real project?

免責聲明:本站內容為個人學習、實作與經驗分享紀錄,部分內容透過 AI 協助修正與整理。由於每位使用者的系統環境、軟體版本、權限設定與操作方式不同,實際結果可能有所差異。請在操作前自行評估風險並備份重要資料。因參考本站內容所造成之任何系統異常、資料遺失、設定錯誤、設備故障、服務中斷或其他直接、間接損失,均由使用者自行承擔,本站與作者不負任何相關責任。

Disclaimer: This site records personal learning, implementation, and experience sharing, with some content edited and organised with AI assistance. Results may differ because every user has a different system environment, software version, permission setup, and workflow. Assess risks and back up important data before trying anything. You are responsible for any system errors, data loss, configuration mistakes, equipment faults, service interruptions, or other direct or indirect losses resulting from using this content.