0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

macOSアップデート後にGitが使えないときの対処法

0
Posted at

はじめに

macOSをアップデートした後、CursorやVSCodeで突然「Gitが見つかりません」と表示されて焦ったことはありませんか?

実はこの現象、原因はほぼ2パターンに絞られ、数分で解決できます。
本記事では、原因の切り分けから対処法までをまとめます。

症状

  • Cursor(またはVSCode)でGitのソース管理が機能しなくなる
  • 「Gitが見つかりません。インストールしてください」といった旨のメッセージが表示される

原因の切り分け

ターミナルで以下を実行します。

git --version

ここで表示されるメッセージによって、対処法が変わります。

パターン①:Xcodeライセンスの未承諾

You have not agreed to the Xcode and Apple SDKs license.
You must agree to the license below in order to use Xcode.

macOSのアップデートにより、Xcodeのライセンス承諾がリセットされたケースです。
Command Line Tools自体は存在しているものの、ライセンスが未承諾のためGitを含むツール群がブロックされています。

パターン②:Command Line Toolsが無効化された

xcode-select: note: No developer tools were found...

macOSのアップデートにより、Command Line Toolsそのものが無効化されたケースです。

対処法

パターン①の場合:ライセンスを承諾する

sudo xcodebuild -license accept

管理者パスワードを入力すれば完了です。

パターン②の場合:Command Line Toolsを再インストールする

xcode-select --install

ポップアップが表示されるので「インストール」をクリックし、完了するまで待ちます。

共通:エディタへの反映

対処後、git --version でバージョンが表示されることを確認します。

git --version
# 例: git version 2.39.5 (Apple Git-154)

Cursor(VSCode)はウィンドウの再読み込みCmd + Shift + PDeveloper: Reload Window)を行えば、Gitが再認識されます。

まとめ

状況 対処コマンド
ライセンス未承諾 sudo xcodebuild -license accept
Command Line Tools が無い xcode-select --install

macOSアップデート後にGitが消えたように見えても、大抵はこの2パターンのどちらかです。慌てずにターミナルで git --version を叩いて、エラーメッセージに応じた対処をしましょう。

同じ症状で困っている方の参考になれば嬉しいです 🙏
※私は慌てました。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?