![]() ![]() Using this, change the default branch to any other branch or select placeholder (if you do not have other branches and you need a dummy branch for now). You will set a dropdown menu for "Default branch".Then, click on "Branches" (on the left side vertical bar).Go to your repository in GitHub using a web browser.Following are the commands to change the default branch in GitHub: If you want to delete the master branch in a GitHub repository, you need to first change the default branch in the concerned repository and then, delete the master branch. This is because in GitHub, the master branch is set as the default branch and hence, cannot be deleted. When dealing with a Git repository hosted at GitHub, the commands in the previous section will not work directly. Delete master branch in GitHub repository You can delete the master branch now using the following commands: git push origin -d masterĬheck the detailed commands to delete a remote branch here. With this, we have made the master branch just a normal branch which you can delete as usual. Replace branch2 with the branch you want to be pointed to by HEAD. If the HEAD reference is the master branch, update the HEAD in your Git repository using the following command: git symbolic-ref HEAD refs/heads/ Use the following command to check the reference for HEAD: git symbolic-ref HEAD Delete master branch in local or remote repositoryįirst, we will check the references in your repository, check if HEAD reference is master and if so, we update it to another reference branch.įind the references in your Git repository using the following command: find ref ![]() The process of deleting a master branch either in local or remote repository will require to address these two points. If master branch is deleted, what will HEAD point to?.If master branch is deleted, there needs to be another active branch.The problem in deleting a master branch is: The HEAD of the Git repository points to this master branch. This is the branch the repository is checked in. In short, the command to delete a master branch is: git symbolic-ref HEAD refs/heads/Įvery Git repository has an active branch which by default is the master branch. It may seem unreasonable that one wants to delete a master branch but in reality, it is reasonable as master branch is just another branch with some special properties which can be transferred to other branches. Delete master branch in GitLab / BitBucket repositoryĭeleting a local branch is one thing and Deleting a master branch is another.Delete master branch in GitHub repository.Delete master branch in local or remote repository.In this article, we have presented the technical details why deleting a master branch is not straight-forward and presented the commands to delete the master branch of any Git repository (local or remote) and also, covered the case when the repository is hosted at GitHub, GitLab or BitBucket. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |