Git 路線圖Git Roadmap單元 03Unit 03
核心操作Core operation

建立第一個版本Create your first version

UNIT 03 · FIRST COMMIT

建立第一個版本Create your first version

真的輸入 init、add、commit,讓普通資料夾長出第一個版本節點。Type init, add, and commit to turn an ordinary folder into a repository with its first version node.

預計時間Estimated time
15–20 分鐘15–20 minutes
單元類型Unit format
教材+模擬器Lesson + simulator
需要先會Prerequisite
單元 1、2Units 1 and 2

第一個 commit 是三個動作,不是一個動作

git init 讓目前資料夾成為 repository;git add 挑選下一個版本要收錄的內容;git commit 才真正建立版本快照。

git init
git status
git add .
git commit -m "建立第一個版本"

git add . 很方便,但工作上應先看 git status,避免把密碼、建置輸出或暫存檔一起加入。初學時也可以改用 git add app.js,更清楚知道自己選了什麼。

commit message 請描述「這個版本完成什麼」,例如「新增登入表單」,不要只寫「更新」或「修改」。

完成後觀察 Git 樹:mainHEAD 會一起指向第一個 commit。Working Directory 與 Staging Area 都會回到乾淨狀態。

Your first commit takes three actions

git init turns the current folder into a repository. git add selects what belongs in the next version. git commit finally creates the version snapshot.

git init
git status
git add .
git commit -m "Create the first version"

git add . is convenient, but check git status first so passwords, build output, or temporary files do not slip in. While learning, git add app.js makes your selection more explicit.

A commit message should describe what this version completed, such as “Add login form”, rather than only “Update” or “Change”.

Afterward, look at the Git tree: main and HEAD point to the first commit together. The Working Directory and Staging Area are clean again.

INTERACTIVE LAB

在安全模擬器裡親手操作

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

A

WORKING DIRECTORY

正在編輯的檔案

  • README.md未追蹤
  • app.js未追蹤
B

STAGING AREA

下一版準備內容

  • Staging Area 是空的
C

LOCAL REPOSITORY

電腦裡的版本

HEAD
尚未 init
目前 commit
尚未建立
commit 數
0
D

REMOTE REPOSITORY

GitHub 示意狀態

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

教學 Terminal

不會執行真實 Git 或 shell

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

點一下填入:

VIRTUAL FILES

虛擬檔案編輯器

更多情境工具

LIVE GIT TREE

尚未建立 repository

執行 git init 後,HEAD 與 main 才會出現。

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.