亀の甲羅2

今日もまた朝とく起きて励まなん窓に明るきありあけの月

【Git】 現在のワークツリーの状態確認:git status (深堀)

タダのメモ

目次

本文

1. 説明

statusもう少し深堀する。

> git status

【git status 実行例】
f:id:takobose_ht:20210925152222p:plain

git statusをオプションなしで実行すると、かなり文字数の多い結果となる。


> git status -s

【git status -s 実行例】
f:id:takobose_ht:20210925152134p:plain

-sオプションで実行すると、簡易的な結果表示となる。
(Mマークの意味はだいたいわかるでしょ。その他に、「A(Add)」「D(Del)」「R(Rename)」)


> git status -sb

【git status -sb 実行例】
f:id:takobose_ht:20210925152152p:plain

さらに-bオプションも合わせてみるとブランチ情報も合わせて表示される。


2. 実行例

◆ワークツリーのファイルを編集した状態

f:id:takobose_ht:20210925152059p:plain

※Mの文字色がRed。

◆ステージに上げてから確認

f:id:takobose_ht:20210925152341p:plain

※Mの文字色がGreen。

◆コミットしてから確認

f:id:takobose_ht:20210925152411p:plain

※Branchにahead記載有。(pushが必要と分かる)

◆pushしてから確認

f:id:takobose_ht:20210925152438p:plain

念のため、statusを確認。

$ git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

綺麗な状態。