1
0

【Git】最新のコミットからの変更があるか確認する方法

Last updated at Posted at 2024-03-06

ステージング前の変更あるか確認する

ステージング前の変更があるか確認するには以下のコマンドを実行します。

git diff --quiet HEAD

変更がある場合に異常終了します。

未追跡のファイルは無視されます。

ステージング後の変更があるか確認する

ステージング後の変更があるか確認するには以下のコマンドを実行します。

git diff --cached --quiet

変更がある場合には異常終了します。

何らかの変更があるか確認する

以下のコマンドを実行すると未追跡のファイルも含めて何らかの変更があるか確認できます。

test -z "$(git status --porcelain)"

git status --porcelainの出力がないかtest -zで検証しています。

変更がある場合には異常終了します。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0