git status
git status 是最常用的指令:告訴你現在在哪條分支、哪些檔改了、哪些已暫存、有沒有還沒 push/pull 的提交。做任何 add、commit、merge 前後都看一眼,比較不容易漏檔或推錯。
基本用法
它會顯示:
- 目前分支名稱。
- 與遠端追蹤分支是否同步。
- staging 裡已準備提交的檔。
- workspace 裡已修改但尚未 add 的檔。
- 從未追蹤的新檔(untracked)。
輸出範例
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: index.html
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: style.css
Untracked files:
(use "git add <file>..." to include in what will be committed)
newfile.js
- On branch main:目前在
main。 - Changes to be committed:已在 staging。
- Changes not staged for commit:工作區有改、還沒 add。
- Untracked files:Git 還沒開始追蹤。