AI Hints
Home›Git & GitHub Tutorial›Old Commands Online
Git & GitHub · Lesson 105 of 144

master and main

The default branch name.

⏱ 2 min read▶ Video at 1:55:41🎓 Free
Watch this lesson in the Git & GitHub courseWatch on YouTube ↗Full Git & GitHub course

In older tutorials and repositories, the main branch is called master. Since around twenty twenty, GitHub and most projects use main instead. They work exactly the same, it's just a name.

master and main
From the video: master and main
  • Older repos use master
  • Newer ones use main
  • Just a name

Renaming a branch

If you have an old repository with master, you can rename it. Git branch dash m, master, main. List the branches, and it's now main. If it's on GitHub, you'd also rename it in the repository's branch settings.

git
git branch
* master
git branch -m master main
git branch
* main

Make main your default

To make every new repository start with main, set init dot default branch to main, once, in your global config. GitHub already uses main for new repositories. And when you join a project, just use whatever name it already has.

Old namemaster
New namemain
Renamegit branch -m master main
Defaultinit.defaultBranch main

Summary

Master is the old name for the main branch. Rename it with git branch dash m. Next, a peek at how Git works inside.

Key takeaways
  • master = old name
  • git branch -m
  • init.defaultBranch main
Next up: Inside Git — objects and snapshots