LoginSignup
3
2

More than 3 years have passed since last update.

Sourcetreeでコミットを行う際に「git: 'secrets' is not a git command. See 'git --help'.」というエラーが表示される。

Last updated at Posted at 2020-12-10

背景

開発中アプリケーションのS3設定を終え、Sourcetreeでコミットを行った際に、
「git: 'secrets' is not a git command. See 'git --help'.」というエラーが表示され、
コミットが出来なかったので、プログラミング初学者ですが、備忘録として記事を書きました。

参考記事:git-secretsをSourceTree (Macintosh)で使えるようにする手順
※ほとんど、上記の記事を参考にしていますので、まずは上記の記事を確認して、実行してみてください。

前提

Sourcetreeの環境設定のgitでは、システムのgitを使用するを選択している状態です。

手順1

「git: 'secrets' is not a git command. See 'git --help'.」というエラーは、git-secretsがインストールされていませんというエラーとのことです。

まず、git-secretsのインストールを行いました。

% brew install git-secrets

すると、下記の結果が返ってきました。

Warning: git-secrets 1.3.0 is already installed and up-to-date

既に、git-secretsはインストールされているとのことです。

手順2

gitの場所の確認を行いました。

% which git
/usr/bin/git

git-secretsの場所の確認を行いました。

% which git-secrets
/usr/local/bin/git-secrets

gitとgit-secretsのパスが違いますね。

readlinkでgit-secretsの場所を確認します。

% readlink git-secrets

私の場合は、変化がありませんでした。
そのため、Finderの「Macintosh HD」から確認しました。
Macintosh HDで「command + shift + .」で隠れファイルを表示します。
私の場合は、Macintosh HD > usr > local > Cellar > git-secrets > 1.3.0 > bin > git-secrets
にありました。
確認が出来ると、下記コマンドを実行します。

% cd /usr/bin
% sudo ln -s /usr/local/Cellar/git-secrets/1.3.0/bin/git-secrets 

すると、下記の結果が返ってきました。

ln: ./git-secrets: Operation not permitted

/usr/local や /usr/bin へのリンクはsudoしても拒否されてしまうみたいです。

手順3

System Integrity Protecton(SIP)を無効にします

  • macをシステム終了し、再度立ち上げます。その際に「command + R」でリカバリーモードを立ち上げます。
  • ユーザーを選択し、パスワードを打ち込み、画面が切り替わると、ヘッダメニューの「ユーティリティ」から「ターミナル」を立ち上げます。
  • ターミナルでSIPコマンド「csrutil disable」を実行します。
  • macをシステム終了し、再度立ち上げます。

SIPが無効化されたら、git-secretsを/usr/bin/にリンクします

% cd /usr/bin
% sudo ln -s /usr/local/Cellar/git-secrets/1.3.0/bin/git-secrets 

すると、下記の結果が返ってきました。

ln: ./git-secrets: Read-only file system

これはgit-secretsが読み取り専用ファイルシステムとのことです。
そのため、下記コマンドを実行し、書き込み権限を付与します。

% sudo chmod g+w /usr/local/Cellar/git-secrets/1.3.0/bin/git-secrets
% sudo ln -s /usr/local/Cellar/git-secrets/1.3.0/bin/git-secrets

※上記コマンドを実行しても、画面の変化はありません。

System Integrity Protecton(SIP)を有効にします

  • macをシステム終了し、再度立ち上げます。その際に「command + R」でリカバリーモードを立ち上げます。
  • ユーザーを選択し、パスワードを打ち込み、画面が切り替わると、ヘッダメニューの「ユーティリティ」から「ターミナル」を立ち上げます。
  • ターミナルでSIPコマンド「csrutil enable」を実行します。
  • macをシステム終了し、再度立ち上げます。

すると、Sourcetreeでコミット・プッシュが出来るようになりました。

3
2
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
3
2