GIT & GITHUB從零開始的 11 單元11 units from the ground up

別再死背指令。Stop memorizing commands.
先看懂版本在哪裡。See where your version really is.

每輸入一條 Git 指令,檔案、branch 與 commit 都會跟著變化。這裡把看不見的狀態畫出來,陪你從第一次 commit 一路走到 GitHub 協作。Every Git command changes files, branches, or commits. We draw those hidden states so you can move from your first commit to working with GitHub.

  • Windows+macOSWindows + macOS
  • 不碰真實檔案No real files touched
  • 繁體中文解說Traditional Chinese guidance
git log --graph --oneline狀態可視化State visualized
  1. HEADmain
    c4合併登入功能Merge login feature
  2. feature/login
    c3完成登入表單Complete login form
  3. c2建立導覽列Create navigation
  4. c1建立專案Create project

現在發生什麼?What is happening?feature/login 從 c2 分出去,完成 c3 後再合回 main,形成 c4。feature/login branches from c2, completes c3, then merges back into main as c4.

01 / 先建立正確心智模型01 / Build the right mental model

一個檔案,會經過四個位置One file, four places

`git add` 不是存檔,`git commit` 也不是上傳。先把四個區域分清楚,後面的 branch、merge 與 GitHub 才不會混在一起。`git add` is not Save, and `git commit` is not Upload. Separate the four areas first, and branches, merges, and GitHub will make much more sense.

Amodified

Working Directory

你正在編輯的實際檔案。The real files you are editing.

app.js
git add
Bstaged

Staging Area

下一次 commit 準備收錄的內容。The changes selected for the next commit.

app.js
git commit
Ccommitted

Local Repository

保存在你電腦裡的版本快照。Version snapshots stored on your computer.

c3 · 新增登入
git push
Dsynced

Remote Repository

GitHub 上與別人共享的版本。The version shared with others on GitHub.

origin/main

02 / 完整學習路線02 / The complete learning path

一次只學一件事Learn one thing at a time

每個單元都會先講觀念,再讓你輸入指令,最後用 Git 樹確認狀態。前一個步驟看懂了,再進下一個。Each unit starts with the idea, lets you type the command, and ends by checking the Git tree. Move on only after the current step makes sense.

  1. 01可開始Ready

    Git 到底在管理什麼What exactly does Git manage?

    先認識四個區域,理解檔案如何一步步變成版本。Meet the four areas and see how files become versions step by step.

    working treestagingrepository
    開始單元Start unit
  2. 02可開始Ready

    安裝與初始設定Install and configure Git

    分別完成 Windows 與 macOS 安裝,設定你的版本作者資訊。Install Git on Windows or macOS and set the author information for your versions.

    configPowerShellzsh
    開始單元Start unit
  3. 03可開始Ready

    建立第一個版本Create your first version

    從空資料夾開始,親手走完 init、add 與 commit。Start with an empty folder and complete init, add, and commit yourself.

    initaddcommit
    開始單元Start unit
  4. 04可開始Ready

    日常查看與修改Inspect and change files daily

    分清楚 untracked、modified、staged,學會看差異與歷史。Tell untracked, modified, and staged apart, then inspect differences and history.

    statusdifflog
    開始單元Start unit
  5. 05可開始Ready

    連接 GitHubConnect to GitHub

    看懂本機與遠端的關係,再練習 push、pull 與 clone。Understand local and remote repositories, then practise push, pull, and clone.

    remotepushpull
    開始單元Start unit
  6. 06可開始Ready

    使用 branch 開發Develop with branches

    建立獨立支線,不影響 main 也能安全嘗試新功能。Create an isolated line of work so you can try features without changing main.

    branchswitchHEAD
    開始單元Start unit
  7. 07可開始Ready

    合併與衝突處理Merge branches and resolve conflicts

    從 Fast-forward 到分叉,逐步解開 merge conflict。Move from fast-forward merges to diverged branches and resolve a merge conflict.

    mergeconflictfast-forward
    開始單元Start unit
  8. 08可開始Ready

    GitHub 協作Collaborate on GitHub

    走完 Pull Request、code review、merge 與同步主分支。Walk through a Pull Request, code review, merge, and syncing the main branch.

    pull requestreviewsync
    開始單元Start unit
  9. 09可開始Ready

    一個人也能維護公開專案Maintain a public project on your own

    從口頭回報走到 Issue、PR review、Actions checks 與結案。Turn a verbal report into an Issue, PR review, Actions checks, and a clear close-out.

    issuemaintaineractions
    開始單元Start unit
  10. 10可開始Ready

    復原與常見事故Undo changes and recover safely

    依照是否提交、是否分享,選對 restore、revert 或 reset。Choose restore, revert, or reset based on whether the change was committed or shared.

    restorerevertreset
    開始單元Start unit
  11. 11可開始Ready

    進階觀念Advanced concepts

    補齊 rebase、cherry-pick、tag 與 .gitignore 的使用時機。Learn when rebase, cherry-pick, tags, and .gitignore solve the right problem.

    rebasecherry-picktag
    開始單元Start unit

03 / 這套網站怎麼教03 / How this site teaches

輸入、觀察、再解釋

不是把答案貼給你,而是先讓你預測下一步,再從 Git 樹和四個區域驗證自己的理解。

Type, observe, then explain

We do not simply paste the answer. You first predict the next step, then verify your understanding with the Git tree and four areas.

  1. 1
    先給一個具體任務Start with one concrete task

    例如:把 app.js 放進 Staging Area。For example: put app.js into the Staging Area.

  2. 2
    親手輸入 Git 指令Type the Git command yourself

    答錯不改動狀態,會告訴你可以觀察哪裡。A wrong answer does not change the state; it points out what to observe.

  3. 3
    看 Git 樹與四區一起更新Watch the Git tree and four areas update

    不只看到「成功」,還知道版本到底移到哪裡。You see more than success—you see exactly where the version moved.

免責聲明:本站內容為個人學習、實作與經驗分享紀錄,部分內容透過 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.