I was trying to push some local unversioned code into a repo and get it up onto GitHub for accessibility reasons.
I followed the suggestions here
cd <local_dir>
git init
git add .
git commit -m "initial commit"
Then I created a new repo on github and did
git remote add origin https://github.com/...
git pull origin master --allow-unrelated-histories
git push --force-with-lease
But I now see on github that I have 2 branches 'main' and 'master' I guess github created 'main' when it created the repo and I created 'master' when I synced from my local repo
Do I need both?
Can I just merge master into main and then delete master?
At present it is just confusing me
Note: I have now tried (locally)
git branch -m master main
git push origin HEAD
but I'm getting an error
To https://github.com/<the-repo>
! [rejected] HEAD -> main (non-fast-forward)
error: failed to push some refs to 'https://github.com/<the-repo>'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Whatt am I missing?
master
as the name of the default branch. Github decided to change itmain
recently. You can choose to pick either. – Urine