git status
git
用法
git status [-sb] [-uall]顯示哪些已暫存、哪些改了、哪些還沒被追蹤;未追蹤的檔案預設只按資料夾折疊顯示,要逐個看得加 -uall。
常用選項
| 選項 | 含義 |
|---|---|
| -s | short two-column format |
| -b | show the branch line, used as -sb |
| -uall | list untracked files one by one instead of folding folders |
| --ignored | also list what .gitignore hides |
| -v | append the staged diff |
| --porcelain | stable machine format for scripts |
範例
git status -sbone line per change plus the branch and its upstream
git status -uallnames every untracked file inside new folders
git status --porcelainoutput a script can parse without surprises
難的地方在於復原有好幾種:把分支的指向挪走,和補一個反向提交,不是一回事。
怎麼看
- 方括號 [ ] 表示這部分可以不寫。
- 省略號 … 表示可以寫多個。
- 選項區分大小寫——有些命令裡 -r 和 -R 不是一回事。
常見問題
Q. git status 是做什麼的?
顯示哪些已暫存、哪些改了、哪些還沒被追蹤;未追蹤的檔案預設只按資料夾折疊顯示,要逐個看得加 -uall。
Q. 怎麼寫?
git status [-sb] [-uall] —— 方括號表示可以省略的部分。
Q. 值得記的選項有幾個?
這裡列了 6 個,完整列表在 man git。這條命令屬於git。
相關命令
man 手冊: man git-status