Whenever I use git push origin main
I get an error saying
error: failed to push some refs to "repo link"
to avoid this I have to use master instead of main to create a different branch altogether but when I visit github it already has main and master and if i rename master as main it again doesn't work.
This is an error I got when I started to learn git, the cause of this error is when you add a remote origin to a git repository, git on the system puts it on master
branch but github has moved from master
to main
(here)
To solve this issue:
git checkout -b main
to switch to main branchgit pull origin main
to pull the main branch, add proper flags if you want to merge or rebase the branchesgit push origin main
to push your work to the main branch.