第一個 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 樹:main 與 HEAD 會一起指向第一個 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.