October 12, 2024

GitHub Replacing Master With Main: What Developers Need To Do Now

0
GitHub Replacing Master With Main What Developers Need To Do Now

In an email sent to GitHub developers on Wednesday, Chris Wanstrath, CEO of GitHub, announced that in October 2014 the company will begin naming branches with the convention main instead of master in all public repositories using the Git version control system. We plan to rename ‘master’ to ‘latest’ and replace it with ‘main’ by default in all new repositories created after October 28th, 2014, said Wanstrath. While this change will primarily impact developers who choose to host their repositories on GitHub, anyone who maintains any type of project that relies on Git should pay attention.

How we got here

In June, GitHub announced that it would be changing the default branch name from master to main as part of its commitment to remove unnecessary references to slavery in software. The announcement sparked a heated debate among developers, with some arguing that the change was unnecessary and would cause confusion, while others welcomed it as a way to signal GitHub’s commitment to inclusivity. So what now? The good news is that all code will still work the same on both branches, so there’s no need to make any changes at this time. But if you want to rename your local repository before October 11th (or anything after), you can use Git’s submodule command like so: git submodule foreach git mv . $1 .

That said, the big question for many has been whether they should rename their repositories and how long they have until they have to do so. $2 As mentioned above, you don’t need to take any action yet; however, we recommend renaming your repositories now if you plan on making other changes in the future because doing so could prevent unintended consequences later. Also, bear in mind that renaming your repository may require renaming tags or branches associated with other projects.

What are branches?

In computer programming, a branch is a section of code within a program that can be executed independently of other code. A branch allows developers to work on different parts of a project at the same time and then merge their changes together. While branches can sometimes lead to conflicts when merged, they are also helpful in many ways. One example is in the case of an emergency or outage. If one part of your website crashes but you have a backup plan, you could continue working on the unaffected sections until you are able to fix it with no interruption in service. The world’s biggest repository for open-source software has already implemented this approach, starting in October. The new way will take over as the default for all repositories and delete any forks that diverge from main too much.

Forking a repo and the risks of forking

When you fork a repo, you’re making a copy of the original project so that you can work on it independently from the main project. However, this also means that you’re cut off from any future updates to the main project. This can pose a problem if the main project is updated in a way that conflicts with your changes. For example, say you add a new feature to your forked version of a project, but then the original project adds a new feature that conflicts with yours. If you want to maintain compatibility with the original project, then you have two options: either back out your changes or edit them so they don’t conflict.

Branch best practices

Now that GitHub is changing its default branch name from master to main, it’s a good time to review your own branch naming conventions. Here are some best practices to keep in mind as you start making changes.

None of these changes should be difficult for teams to implement, but they do require significant coordination and planning on the part of development managers.

  • Change the branch name from master to main on all relevant repositories in order to ensure consistency across projects
  • If the repository uses submodules, change the remote url prefixes and update any references accordingly
  • Update any CI scripts or scripts running against branches with a switch statement so they account for different branch names

Leave a Reply

Your email address will not be published. Required fields are marked *