Git入門 その13 / git status
環境 git version 1.8.3.1
■ git status
ローカルリポジトリとステージングエリア、ローカルディレクトリの状態を表示する。
# ファイルを追加 $ echo hoge > hoge.txt $ git add hoge.txt # ファイルを変更 $ echo fugafuga > fuga.txt # 状態の確認 $ git staus # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: hoge.txt # # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: fuga.txt # # 変更状態だけ表示 $ git staus -s M fuga.txt A hoge.txt # ブランチも表示 $ git status -s -b ## master M fuga.txt A hoge.txt
"git status -s"のステータスコードは以下の意味を表し、1文字目がステージングエリア、2文字目はローカルディレクトリを示す。
ステータスコード | 意味 |
---|---|
(空白) | 身変更 |
A | 追加 |
M | 変更 |
D | 削除 |
R | リネーム |
C | コピー |
U | 未マージの変更 |
? | 未追跡(一度もステージングに追加されていない) |
例えば
# 当たらしくファイルを追加すると $ touch newfile $ git status -s ?? newfile # git addすると $ git add newfile $ git status -s A newfile # git commitすると表示されなくなる $ git commit -m "add newfile" $ git status -s $ # 変更すると $ echo change > newfile $ git status -s M newfile # git addで追加すると $ git add newfile $ git status -s M newfile
となる
takafumi-s.hatenablog.com