I've struggled with this forever, so here's the full process I've pieced together from many posts:
Make an access token for your GitHub account. Click on your profile, go to dev settings, and create a classic token.
Check off the following and then click "generate token"
✅repo
✅workflow
✅user
✅write:discussion
✅admin:enterprise
✅admin:gpg_key
Double-check that you have added, committed, and merged all changes.
In the command line interface, type these commands. Replace <space holders> with your personal information.
a) git config --global user.email <yourEmail>
b) git config --global user.name “<yourUrerName”
c) git remote set-url origin <urlForYourRepo>
(if no repo currently exists, use this command instead) git remote add origin <urlForYourRepo>
d) git branch -M main
e) git push -u origin main
Now it should ask for your GitHub username and password. In place of your password, use the access token you made earlier.