When you clone a remote repository, by default your local working directory will be on the remote repository's default branch. For a long time this was the master
branch, but GitHub has recently started using the name main
instead of master
.
It sounds like your repository may have been created someplace else and then pushed to GitHub. Regardless of how you arrived at this situation, you have two branches named main
and master
, and it sounds like main
is the default branch.
After cloning the repository, you will be on the main
branch. You can switch to the master
branch by running:
git switch master
Or:
git checkout master
The git switch
syntax is newer. The two commands are largely equivalent (git checkout
does more than git switch
).
You can change the default branch of your GitHub repository by going to your repository settings. Clicking on "Branches" along the left. This will take you to the branch settings, where the first section is the "Default branch" section.
Click on the icon with two arrows, then select master
as your default branch.
In the future, git clone
will result in a working directory that is on the master
branch.