日々精進

新しく学んだことを書き留めていきます

masterブランチの名前をproductionにする方法

最近本番、テスト、開発の各環境用にブランチを切る運用がはやってるけど、本番環境用ブランチの名前がmasterとなるのは違和感があるので名前をproductionにしたい・・・という場合は以下で名前を変えられる。

git checkout -b production master    # create and switch to the production branch
git push -u origin production        # push the release branch to the remote and track it
git branch -d master              # delete local master
git push --delete origin master   # delete remote master
git remote prune origin           # delete the remote tracking branch

参考:version control - How do I rename my git 'master' branch to 'release'? - Stack Overflow
後、Githubではデフォルトブランチをdevelopにしといた方がいいですね。
やり方は↓
Setting the default branch