git status
作業ツリーの現在の状態を表示します。変更されたファイル・ステージング済みのファイル・未追跡のファイルを確認できます。
構文
git status [options] git status は、作業中のリポジトリの状態を把握するための最も基本的なコマンドです。Git を使うときは頻繁に実行して、現在の状態を確認する習慣をつけましょう。
基本的な使い方
git status
出力の読み方
On branch main
Your branch is up to date with 'origin/main'.
Changes to be committed: ← ステージング済み(次のコミットに含まれる)
(use "git restore --staged <file>..." to unstage)
new file: README.md
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: src/index.js
Untracked files: ← Git が追跡していない新規ファイル
(use "git add <file>..." to include in what will be committed)
logs/debug.log
簡略表示
git status -s
A README.md ← A: ステージング済みの新規ファイル
M src/index.js ← M: 変更済み(ステージング前)
M config.json ← M: ステージング済みの変更
?? logs/debug.log ← ??: 未追跡ファイル
1文字目はステージングエリアの状態、2文字目は作業ツリーの状態を示します。
ファイルの状態一覧
| 状態 | 説明 |
|---|---|
| Untracked | Git が追跡していない新規ファイル |
| Modified | 追跡済みで内容が変更されたファイル |
| Staged | git add でステージングされたファイル |
| Committed | コミット済みで変更のないファイル |