Configure an existing Github repo to use a different default branch

Share this video with your friends

Social Share Links

Send Tweet
Published 4 years ago
Updated 4 years ago

By default, git provides master as the default branch. This lesson shows how to get round that and use an alternative as the default branch for an existing repo.

Kevin Cunningham: [0:00] This is my blog, which I've had for a while. You can see my default branches at the master. What I'm going to do is I'm going to create a new branch in my local. I will make sure that I've pushed up all my changes. Everything's up to date. Great.

[0:19] What I'm going to do now is I'm going to create a new branch main, like that. Then, I'm going to push that branch up to GitHub. That will fail because I haven't created it in the upstream, so I'm going to go create --set-upstream origin main. If I refresh my GitHub page, I can see I do have now a main branch.

[0:51] What I'm going to do now is I'm going to go to Settings. I'm going to go to Branches. Here, it says my default branch and it's set to master. I'm going to switch that to main and update that. My default branch is now main.

[1:11] Finally, I just want to remove that branch. I'm going to go to branches. I see that's main. I have these other branches. I'm going to just delete the master branch. That's it. Master branch is gone.

egghead
egghead
~ 11 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today