【Git】error: unknown option `initial-branch=main'
gitでエラーが出た;
% git init --initial-branch=main error: unknown option `initial-branch=main' usage: git init [-q | --quiet] [--bare] [--template=<template-directory>] [--shared[=<permissions>]] [<directory>] --template <template-directory> directory from which templates will be used --bare create a bare repository --shared[=<permissions>] specify that the git repository is to be shared amongst several users -q, --quiet be quiet --separate-git-dir <gitdir> separate git dir from working tree
--initial-branch
オプションをご存知でない!?
gitのバージョンが古いだけでした。
gitをアプデしましょう。
以上。
蛇足
エラー吐いたときのGitのバージョン;
% git --version git version 2.24.1
Gitは、どうやら、Homebrewでインスコしてた模様;
% where git /usr/local/bin/git <- Homebrew /usr/bin/git <- macOSランタイム? % ls -go /usr/local/bin/git lrwxr-xr-x 1 28 12 20 2019 /usr/local/bin/git@ -> ../Cellar/git/2.24.1/bin/git % ls -l /usr/bin/git -rwxr-xr-x 76 root wheel 167120 5 10 06:30 /usr/bin/git*
最新のバージョンを確認します。
まずはbrew update
でHomebrew(自身)を最新版にアプデします;
% brew update ... % brew -v Homebrew 3.5.4 Homebrew/homebrew-core (git revision 1abcad8993b; last commit 2022-07-09) Homebrew/homebrew-cask (git revision 0ec7c70cf3; last commit 2022-07-09)
Gitの最新安定版は2.37.0
のようです;
% brew outdated git git (2.24.1) < 2.37.0 % brew info git git: stable 2.37.0 (bottled), HEAD Distributed revision control system https://git-scm.com /usr/local/Cellar/git/2.24.1 (1,554 files, 45.5MB) * Poured from bottle on 2019-12-20 at 23:31:19 From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/git.rb License: GPL-2.0-only ==> Dependencies Required: gettext ✔, pcre2 ✘ ==> Options --HEAD Install HEAD version ==> Caveats The Tcl/Tk GUIs (e.g. gitk, git-gui) are now in the `git-gui` formula. Subversion interoperability (git-svn) is now in the `git-svn` formula. zsh completions and functions have been installed to: /usr/local/share/zsh/site-functions Emacs Lisp files have been installed to: /usr/local/share/emacs/site-lisp/git ==> Analytics install: 267,859 (30 days), 859,304 (90 days), 3,005,421 (365 days) install-on-request: 262,165 (30 days), 840,650 (90 days), 2,942,147 (365 days) build-error: 36 (30 days)
というわけで、Gitをアプデします;
% brew upgrade git
以上で、Gitをアプデできました;
% git --version git version 2.37.0
--initial-branch
オプションもちゃんと使えるようになっていました;
% git init --initial-branch=main Initialized empty Git repository in /Users/hoge/Desktop/test/.git/
めでたしめでたし