ステージング前の変更あるか確認する
ステージング前の変更があるか確認するには以下のコマンドを実行します。
git diff --quiet HEAD
変更がある場合に異常終了します。
未追跡のファイルは無視されます。
ステージング後の変更があるか確認する
ステージング後の変更があるか確認するには以下のコマンドを実行します。
git diff --cached --quiet
変更がある場合には異常終了します。
何らかの変更があるか確認する
以下のコマンドを実行すると未追跡のファイルも含めて何らかの変更があるか確認できます。
test -z "$(git status --porcelain)"
git status --porcelain
の出力がないかtest -z
で検証しています。
変更がある場合には異常終了します。