7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

git initのデフォルトブランチ名をmasterからmainに変更する

Posted at

GitHubではデフォルトブランチ名がmasterからmainに変更になっているし、git initをすると以下のように警告される。

% 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>
Initialized empty Git repository in /Users/.../.git/

毎回、git init -b mainで指定することもできるが、素直にinit.defaultBranchを設定することにする。

% git config --global init.defaultBranch main

git config -lで確かめると

% git config -l
・・・・・
init.defaultbranch=main
・・・・・

となっており、試しにgit initしてみると、hint:は表示されなくなった。

% git init
Initialized empty Git repository in /Users/.../.git/
7
4
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
7
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?