LoginSignup
1
1

More than 3 years have passed since last update.

コミットする際のcommit failed - exit code 1 received with output: git: 'secrets' is not a git command. See 'git --help'.のエラー対処法

Posted at

Gitにてブランチをコミットしようとした際にエラーが出てコミットできなくなったのでその対処法を記載しておこうと思います。(ツールはGithubDesktopを使用しております。)

このエラーはコミットする際にgit-secretsを利用するファイルはあるけどgit-secretsがないですよ、ということを意味しています。(ぼくの解釈ですが。。。)

このエラーの対処法は主に2つあります。

.git/hooks

1つ目の方法はリポジトリ内の.git/hooksにある「commit-msg, pre-commit, prepare-commit-msg」という実行ファイルを削除する方法です。

$ ls  #カレントディレクトリにあるファイルやディレクトリを表示する
$ ls -l  #ファイルやディレクトリの詳細も同時に表示する
$ ls -a  #隠しファイルも含めファイルやディレクトリを全て表示する
$ ls -la  #隠しファイルを含む全てのファイルやディレクトリの詳細を表示する

.git/hooksは隠しファイルなのでlsコマンドを使用しファイルの場所を確認します。

$ rm test.html  #test.htmlを削除する
$ rm -r test  #testというディレクトリとその中身を削除する
$ rm -f test  #testというファイルを警告なしで削除する
$ rm -rf test  #testというディレクトリとその中身を警告なしで削除する

ディレクトリとファイルの場所を確認したらrmコマンドで「commit-msg, pre-commit, prepare-commit-msg」のファイルを削除します。

git-secretsをインストールする

2つ目の方法はHomebrewにgit-secretsをインストールする方法です。

$ brew install git-secrets

こちらのコマンドを入力すれば完了です。

以上どちらかの方法でコミットできるようになるかと思います。

1
1
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
1