Earth

Rename git master to main

Geert Gerritsen
1 min readJun 15, 2020

Inspiration hit when reading Scott Hanselman’s post about renaming the master branch to main to make our language as tech sector more inclusive.

To make this operation easier, here’s a small script to run for easily renaming the master branch to ‘main’ for any git project:

Couple of caveats:

  • A manual step is needed in the middle of the script to update the default branch to main
  • Only tested on Mac OS, will probably fail on Unix due to sed differences
  • Only works for GitHub-tracked projects

Feedback?

Send it my way! You can find me on Twitter.

--

--

Geert Gerritsen

Freelance backend developer. Follow me on Twitter where I tweet about software, productivity and golang, among other things.