{
    "componentChunkName": "component---src-templates-blog-post-js",
    "path": "/2022-09-01_change_git-init-default-branch/",
    "result": {"data":{"site":{"siteMetadata":{"title":"365"}},"markdownRemark":{"id":"d0751a99-1256-5fed-a5a3-be9422eb6889","excerpt":"git init すると master ブランチが作成されたので main ブランチに変更する 事象 git init すると下記のような hint が表示された hint に書いてあるとおり  で変更ができる 対応 確認  を削除後、  を行う もうひとつの対応方法 git init 時に指定する方法","html":"<p>git init すると master ブランチが作成されたので main ブランチに変更する</p>\n<h2>事象</h2>\n<p>git init すると下記のような hint が表示された</p>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ git init\nhint: Using &#39;master&#39; as the name for the initial branch. This default branch name\nhint: is subject to change. To configure the initial branch name to use in all\nhint: of your new repositories, which will suppress this warning, call:\nhint:\nhint: \tgit config --global init.defaultBranch &lt;name&gt;\nhint:\nhint: Names commonly chosen instead of &#39;master&#39; are &#39;main&#39;, &#39;trunk&#39; and\nhint: &#39;development&#39;. The just-created branch can be renamed via this command:\nhint:\nhint: \tgit branch -m &lt;name&gt;\nInitialized empty Git repository in /Users/user/workspace/tmp/project/.git/\n\n$ git branch --show-current\nmaster</code></pre></div>\n<p>hint に書いてあるとおり <code class=\"language-text\">git config --global init.defaultBranch &lt;name></code> で変更ができる</p>\n<h2>対応</h2>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ git config --global init.defaultBranch main\n$ git config --list | grep &quot;init.defaultbranch=&quot;\ninit.defaultbranch=main</code></pre></div>\n<h2>確認</h2>\n<p><code class=\"language-text\">.git</code> を削除後、 <code class=\"language-text\">git init</code> を行う</p>\n<div class=\"gatsby-highlight\" data-language=\"sh\"><pre class=\"language-sh\"><code class=\"language-sh\">$ rm -rf ./.git/\n\n$ git init\nInitialized empty Git repository in /Users/user/workspace/tmp/project/.git/\n\n$ git branch --show-current\nmain</code></pre></div>\n<h2>もうひとつの対応方法</h2>\n<p>git init 時に指定する方法</p>\n<p><code class=\"language-text\">git init -b &lt;name></code></p>\n<div class=\"gatsby-highlight\" data-language=\"text\"><pre class=\"language-text\"><code class=\"language-text\">$ git init -b development\nInitialized empty Git repository in /Users/user/workspace/tmp/project/.git/\n\n$ git branch --show-current\ndevelopment</code></pre></div>","frontmatter":{"title":"git init 時のデフォルトブランチを変更する","date":"2022/09/01","description":"git init すると master ブランチが作成されたので main ブランチに変更する"}},"previous":{"fields":{"slug":"/2022-08-24_marp-cli/"},"frontmatter":{"title":"marp-cli をいろいろ触る"}},"next":{"fields":{"slug":"/2022-09-02_ansible_interpreter_warning/"},"frontmatter":{"title":"Ansible 実行時に warning が出力されるので対応する"}}},"pageContext":{"id":"d0751a99-1256-5fed-a5a3-be9422eb6889","previousPostId":"6c25f7c2-e272-52de-a91d-6fb4d4c8e321","nextPostId":"2d387ddf-767f-5b8e-be89-2b28d14911bd"}},
    "staticQueryHashes": ["2841359383","3257411868"]}