問題点
Windows環境でgit-secretsを導入すると、Git Bash上では問題なく動作しますが、Visual Studio上でコミットすると、/usr/bin/env: 'bash': No such file or directory
というエラーが表示され、コミットできなくなります。
原因
git-secretsで利用しているスクリプトのシバンに#!/usr/bin/env bash
が指定されているのが原因でした。
対策
git-secretsで利用しているスクリプトのシバンを#!/usr/bin/env bash
から#!/bin/sh
に変更します。具体的には以下のファイルの先頭行を変更しました。
- %USERPROFILE%\.git-secrets
- (ローカルリポジトリのルート)\.git\hooks\commit-msg
- (ローカルリポジトリのルート)\.git\hooks\pre-commit
- (ローカルリポジトリのルート)\.git\hooks\prepare-commit-msg
参考