LoginSignup
3

More than 1 year has passed since last update.

ローカルのgitのデフォルトブランチをmainにしておくメモ

Last updated at Posted at 2021-05-03

最近はmasterだと怒られるようになりましたね。

$ git config --global init.defaultBranch main

を実行しておくだけでOKです。

世の中的にmaster廃止でmainをデフォにする動き

GitHub上で新規リポジトリ作るとmainになってましたが、ローカルから作るとまだmasterがデフォルトになってました。

新しいGitHubリポジトリではmainブランチがデフォルトに

最近CLIツールをアップデートしましたが、gitのv2.30.1で怒られました。

$ git init

hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint: 
hint:   git config --global init.defaultBranch <name>
hint: 
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint: 
hint:   git branch -m <name>

みたいな感じで怒られました。

ローカルで作るとmasterだしタイプぐせもついてたから気にせずgit push origin masterとか打ってしまうのでmasterにしてましたが、 そろそろ世の中に合わせないといけないタイミングみたいですね。

ローカルでもmainにしていきましょう。

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