I have created a Repository as the default main branch.
Step I tried to add to the repository:
- git config --global init.befaultBranch main
- git init -b main
- git add .
- git commit -m "commit to main branch"
- git remote add origin 'my git url'
Now I have stuck to push to the origin
I have tried git push -u origin main but it gave me an error as:
! [rejected] main -> main (fetch first) error: failed to push some refs to 'my git url'
How to push the code from my local machine to GitHub in the main branch?
Any help and pointing to the documentation will be appreciated.
I tried to pull first and there is also an error on doing that:
$ git pull origin main
From
my git url* branch
main -> FETCH_HEAD fatal: refusing to merge unrelated histories