このページで分かること
git:// を https:// に置き換える設定(insteadOf)の仕組みと影響範囲。前提
pubspec.yamlの依存がGitHub等のリポジトリを git: 参照で指定しているときに起きる。Flutter SDKのバージョンに関係なく、git参照の依存を取り込む場面で発動する。
flutterで"pub get"しようとすると以下のようなエラーが出る。
Git error. Command: `git clone --mirror git://github.com/tcd93/super_tooltip D:\Downloads\flutter_windows_2.10.4-stable\flutter\.pub-cache\git\cache\super_tooltip-776fa8d9a4f6641193ad4c97e7ed93bfa09af7f8`
stdout:
stderr: Cloning into bare repository 'D:\Downloads\flutter_windows_2.10.4-stable\flutter\.pub-cache\git\cache\super_tooltip-776fa8d9a4f6641193ad4c97e7ed93bfa09af7f8'...
fatal: remote error:
The unauthenticated git protocol on port 9418 is no longer supported.
Please see https://github.blog/2021-09-01-improving-git-protocol-security-github/ for more information.
exit code: 128
gitのアクセス方法をhttpsにすることで凌いだ。
git config --global url."https://".insteadOf git://
この対処で何が起きるか
url."https://".insteadOf git:// は「git://で始まるURLをすべてhttps://に読み替える」git設定だ。以降の git clone や flutter pub get はgitプロトコルではなくhttpsでアクセスする。--global を外せばそのリポジトリだけ、--system なら全ユーザーに効く。解除は git config --global --unset url."https://".insteadOf だ。ほかによくあるpub getエラー
git@github.com:...)に切り替える。flutter upgrade か、pubspec.yamlのdependency_overridesで参照先を固定して切り分ける。Q. なぜgitプロトコルが使えなくなったのか。
A. GitHubが2022年1月11日にgit://(ポート9418)のサポートを廃止したためだ。GitHub Blog(参考URL)で周知されていた。
Q. 設定を元に戻すには。
A. git config --global --unset-all url."https://".insteadOf を実行するか、~/.gitconfig から該当行を削除する。
Q. Windowsでも同じコマンドで直るか。
A. 直る。Git Bash・PowerShellどちらでも、gitが入っていれば同じ git config --global url."https://".insteadOf git:// が使える。
関連ページ
※ 本ページのAmazonリンクにはアフィリエイトタグ(toobf6-22)が付いている。
🤖 このページにはAIエージェント(ノア)による編集・加筆が含まれます。内容の正確性は保証できないため、重要な判断は一次情報でご確認ください。