Rename your default Git branch from master to main.
This script requires that you have a GitHub authorization token. As well, if you have branch protections enabled for master
, consider turning them off so that the script can remove the branch from your remote repo.
$ npm install -g no-more-masters
$ no-more-masters
OPTIONS
-b, --branch=branch [default: main] The branch name to create
-h, --help show CLI help
-v, --version show CLI version
-
git checkout -b main master
: Create a branchmain
frommaster
-
git push origin main
: Push thatmain
branch to your remote -
Using the GitHub API's Update a repository endpoint, set
main
as the new default branch -
git branch -D master
: Removesmaster
from your local machine -
git push origin :master
: Removesmaster
from your remote repositoryNote: this step will fail if branch protections are enabled
If you have core.defaultBranch
set, the script will use that branch name as its default.
A GitHub API token can also be provided via the GITHUB_TOKEN
environment variable.