1. Create 'main' branch $ git branch -m master main A new branch called 'main' is created using the 'git branch [branch] [newbranch]' command. By passing the '-m ' argument to this git branch management command, the commit histories are copied to the new branch. 2. Push 'main' branch contents to GitHub $ git push origin main The contents of the newly created 'main' branch is pushed to GitHub. 3. Modify symbolic-refs to point to the 'main' branch $ git symbolic-ref refs/remotes/origin/HEAD refs/remotes/origin/main; git branch -a Using the 'git symbolic-refs' command, the HEAD file is edited to point to the 'main' branch instead of the previous 'master' branch. In this example, the HEAD file is the symbolic reference to the current branch. 4. Set the 'main' branch as GitHub default Go to GitHub and access the account settings. In the settings page, click the branches option on the side-panel. This will give the options to change the default repository. Set the 'main' branch as the default. If there are any issues in finding the right settings, GitHub has great documentation on how to change the default branch. It is available here: https://docs.github.com/en/github/administering-a-repository/changing-the-default-branch 5. (Optional) Delete the 'master' branch $ git push origin --delete master -- OR -- $ git push origin :master The last step is to remove the 'master' branch. By using the 'git push [remotename] --delete [branch]' command, the 'master' branch is deleted. The shorter git command 'git push [remotename] :[branch]' does exactly the same as the previous command, but, it could be difficult to remember. References
1. https://www.r-bloggers.com/2020/07/5-steps-to-change-github-default-branch-from-master-to-main/ 2. https://git-scm.com/book/ms/v2/Git-Branching-Branch-Management 3. https://git-scm.com/docs/git-symbolic-ref 4. https://git-scm.com/book/en/v2/Git-Internals-Git-References 5. https://stackoverflow.com/questions/2003505/how-do-i-delete-a-git-branch-locally-and-remotely
0 Comments
Your comment will be posted after it is approved.
Leave a Reply. |
OverviewMoad Computer is an actionable insights firm. We provide enterprises with end-to-end artificial intelligence solutions. Actionable Insights blog is a quick overview of things we are most excited about. Archives
November 2022
Categories |