![]() ![]() Regardless of the reason, renaming a branch can help make your Git workflow more efficient and organized. Perhaps the branch was created with a name that is no longer relevant, or maybe it was named incorrectly in the first place. Renaming a Git branch can be a useful and necessary task in the software development process. ![]() If they depend on a specific "origin/master" branch, you might have to change their settings, too.By following the guidelines and best practices outlined in this guide, you can rename your Git branches with confidence and keep your codebase organized and up-to-date. ![]() One thing to keep in mind, though, is your toolchain: if you're using a CI/CD tool, GitHub Actions, Azure DevOps / Atlassian Bamboo / GitLab CI pipelines or anything like this, you should check these tools thoroughly. Take a look at the following video to see those steps in action: Things to Keep in MindĪs you've seen, the process of renaming "master" to "main" isn't terribly complicated. Create a new tracking connection with the new "origin/main" branch.Remove the existing tracking connection with "origin/master".Get the latest commits (and branches!) from the remote by performing a "Fetch".Here's an overview of what they have to do: If other people on your team have local clones of the repository, they will also have to perform some steps on their end. If you try again now, deleting "master" from the remote repository should be successful! What Your Teammates Have to Do You will then be able to delete the old "master" branch on the remote.Īs an example, here's how to do this in GitHub: GitHub and Gitlab), you have to change the "default" branch or remove any "protected" status for "master". You can simply try right-clicking that branch in the sidebar and choose the "Delete." option from the contextual menu.Ĭhances are, however, that you will be presented with an error message! The reason for this is that in many Git hosting platforms (e.g. What's left is to delete the old "master" branch on the remote repository. Step 3: Delete the Old "master" Branch on the Remote You can do so by dragging it in the sidebar and dropping it onto the remote (e.g. Step 2: Push the Renamed Local Branch to the RemoteĪs a second step, you need to publish your new (or, more appropriately: renamed) "main" branch on your remote repository. You can do that simply by right-clicking the branch in the sidebar and then choosing the "Rename." option from the contextual menu. ![]() Step 1: Rename Your Local Branchįirst of all, you should rename your local "master" branch to "main". This short article will help you rename "master" in your own Git repositories to "main" (or any other term your team has chosen). But the most popular term seems to be "main". In the public discussion, a handful of different alternatives for "master" have popped up, "default" and "primary" being some of them. Fortunately, many people have become aware that this terminology (even more evident in "master/slave") should be replaced! The tech industry should move to a more inclusive, open culture - and removing language like "master/slave" is an important step in this journey. For the longest time, the default branch in most Git repositories was named "master". ![]()
0 Comments
Leave a Reply. |