LoginSignup
1
0

More than 1 year has passed since last update.

The '.git/hooks/pre-commit' hook was ignored because it's not set as executable.の対処

Posted at

結論

pre-commitに対して実行権限を付与。

chmod +x .git/hooks/pre-commit

環境

OS: macOS Big Sur
PHP: 8.0
Laravel: 8.0

Docker Desktop for macも使用

現象

phpmdやphp-cs-fixerをpre-commitフックを使って、コミット時に問題の検出とコード整形を自動化しようとして、
[プロジェクト名]/.git/hooks/pre-commitにpre-commitのスクリプトを記述。

「よっしゃこれで手動でコマンド打たんでもよーなったで!」

コンソールに表示されたエラー
hint: The '.git/hooks/pre-commit' hook was ignored because it's not set as executable.
hint: You can disable this warning with `git config advice.ignoredHook false`.

無視された。

「おいらの書いたスクリプトは見る価値もないのか。。。」

原因

実行権限がない

対策

実行権限を与える。
以下のコマンドを実行。

chmod +x .git/hooks/pre-commit

+は、指定した権限を付与する変更方法
xは実行権限

+x実行権限を付与するという意味になるようです。

「it's not set as executable.のことか!」って気づきました。
権限とかそういうワードを出力してよ〜って思いました。

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