Moad Computer, the actionable insights company
  • Home
  • Contact
  • Shop
  • Blog
  • Home
  • Contact
  • Shop
  • Blog
Search

Actionable Insights blog




Switch default GitHub branch from 'master' to 'main'

4/28/2021

0 Comments

 
Picture
Dr. Rahul Remanan,
CEO, Moad Computer
1. Create 'main' branch
$ git branch -m master main
Picture
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
Picture
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
Picture
Picture
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
Picture
Picture
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.

    Overview

    Moad 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
    October 2022
    September 2022
    August 2022
    July 2022
    June 2022
    May 2022
    April 2022
    March 2022
    February 2022
    January 2022
    December 2021
    November 2021
    October 2021
    September 2021
    August 2021
    July 2021
    June 2021
    May 2021
    April 2021
    March 2021
    February 2021
    January 2021
    December 2020
    November 2020
    October 2020
    May 2020
    April 2020

    Categories

    All

    RSS Feed

Location

Our mission:

Cutting edge, insightful analytics using AI, for everyone.

Contact Us

    Subscribe Today!

Submit
  • Home
  • Contact
  • Shop
  • Blog