master by default; GitHub and newer Git default to main. Functionally they're identical — a branch name is just a label, and neither is special to Git.Guide
Your branch says master, every tutorial says main. Renaming takes four commands.
An older Git installation created your branch as master, but every modern
tutorial — and GitHub itself — assumes main. The mismatch usually surfaces when
you paste a tutorial's push command:
What you see
$ error: src refspec main does not match any What you see when you push to main but your branch is called master. This is Git's message, not a command to run.
A branch name is just a label — neither master nor main is special
to Git. New GitHub repos (and new Git versions) default to main, older setups
used master. Renaming is safe: your history, commits and files are untouched;
only the label changes.
The rename
$ git branch -m master main
$ git push -u origin main main-m = move/rename. The push creates main on GitHub alongside the old master.
GitHub still thinks master is the repo's default branch (the one PRs target and
visitors see). Switch it, then delete the old branch:
Switch the default, delete the old
$ git push origin --delete master mainMake main the default for new repos
$ git config --global init.defaultBranch main git init starts on mainTip: renaming a branch other people work on? Tell them first — their clones still point at the old name, and each teammate runs the same git branch -m locally after pulling.
Up next: the one-page Cheat Sheet — every command, its VS Code equivalent, and what it means.
FAQ
master by default; GitHub and newer Git default to main. Functionally they're identical — a branch name is just a label, and neither is special to Git.git push -u origin main), switch GitHub's default branch in Settings, and tell teammates so they rename their local copies too.main, but no branch with that name exists — yours is probably still called master. Either push master, or rename it first with git branch -m master main.git config --global init.defaultBranch main. Every future git init then creates main from the start.