MasterToMain
MasterToMain
lets you change an old default branch on github or github
enterprise to a new branch. For example, if you wanted to change master
to
main
.
While master
does have meanings that connote expertise or original record, it also
has meanings that have much more oppressive and violent histories. Whether or not the
original meaning of master
branch was in reference to original record or the opposite
of slave matters less than what it may mean to a reader who doesn't want to bother with
the history of git.
Per the twitter thread below, maybe we can just think of it as:
Agreed. All it does is make the world a tiny bit more welcoming.
Thanks to @shanselman for the suggestion.
Installation
You need ruby and rubygems to use master_to_main
.
With ruby gems installed you can simply run
$ gem install master_to_main
Functionality
MasterToMain
has 3 actions:
update
- Update github, pull requests, branch protections, local originupdate_local
- For people to use afterupdate
to update the local cloneupdate_docs
- If you just want to search docs for github urls.
update
Usage
master_to_main update
After filling out the relevant prompts you will be able to:
- Create a new branch (e.g.
main
) if it does not exist. - Clone all branch protections from an old branch.
- Caveat: This does not include the signed commit requirement
- Change the default branch of your repository
- Rebase all pull requests based on your old branch to your new branch
- Change the local
origin
remote value in github.
You will be prompted for:
- Your "github" (e.g. "github.com" or "github.mycompany.com", default is based
on Fetch URL of
origin
or "github.com") - Your user (default is based on Fetch URL of
origin
orwhoami
) - The repository you want to update (default is based on Fetch URL of
origin
orpwd
) - The current default branch (default is
master
) - The desired default branch (default is
main
) - Your personal access token (instructions for settings one can be found here)
- You should enable "repo" access
update_local
Usage
master_to_main update_local
This will perform the following (assuming "master" and "main")
$ git checkout master
$ git branch -m master main
$ git fetch
$ git branch --unset-upstream
$ git branch -u origin/main
$ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
All credit for this goes to "Brad from XUnit.net!" per Scott's Blog.
update_docs
Usage
master_to_main update_docs
This will attempt to update all references to commits on the master branch with commits on the main branch.
TODO
- Testing would be nice
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/dewyze/master_to_main. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.
Code of Conduct
Everyone interacting in the MasterToMain project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.