![]() This warning helps us understand that we’ll close any open pull requests against master and potentially affect any cloned or forked repositories. On GitHub, select settings, branches, and in the drop-down pick main.Ĭlick OK to the warning. This gets the branch up on GitHub, but doesn’t yet make it the default. We can also see origin/master, the reference on GitHub. We can see the master branch, and HEAD is pointing to this branch. When we clone the repository, this is the branch we’ll first have checked out. ![]() The default branch is the one shown when we first load GitHub, the README.md is shown below our code. Let’s transition a repository that’s shared among our team. Is your goal to make a change or to make a statement? Change default branch on GitHub We can verify the change is made successfully:Īfter all, no one will notice. This creates the new branch and checks it out at the same time. Open a terminal in the repository and let’s get the current log: Maybe this repo is for a personal pet project, or maybe it’s an experiment that we did quickly. Let’s transition a local repository that isn’t pushed anywhere. Let’s look at two scenarios: changing a local repository, and changing a repository on GitHub. The next step is to delete the master branch on GitHub.Renaming the default branch in Git from master to main is easy. Now that we have a main branch on our local computer, a main branch up on GitHub, and the default branch on GitHub is the main branch. Nice job! One more step to get, we just need to get rid of the master branch so that the main branch is the only branch. ![]() Next, click the arrows to change the default branchĪfter the default branch change, you can go back to the main repo page and see that main is now the default branch. Then on the lefthand menu, click on branches On the main page for your repo, click on settings. We are going to change it so the default repo and the checkmark are next to the main branch. If you go to the main repo page on GitHub and select the branches dropdown menu, you will see two branches listed and a checkmark next to master. You need to do this on GitHub, not on your local computer. You can see which branch you are on using the command below:Ĭhange the default branch on GitHub to main The first step is to create a new branch locally (on your computer) called main. Step 1Ĭreate a new main branch locally, taking the history from master So change all of your GitHub repo names to main. ![]() This is confusing and leads to creating new branches that you don't want. Is the master branch in charge of anything? Are other branches subservient to it? And a very practical reason is that since GitHub moved to use main as the default branch, you have to remember when to use git push origin main and when to use git push origin master on a repo-to-repo basis. In addition, the name main just makes more sense. Language in programming, like master, that supports symbols of racism has no place. The reason to use the name main as the default branch on Github and in your local git repos is that it's the right thing to do. Git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |