How to git init local repo in github

Follow the command below,

git init -b main

#----------------------------

#optional if your Git 2.27.1 or an earlier version,
git init && git symbolic-ref HEAD refs/heads/main

#----------------------------

$ git add .
# Adds the files in the local repository and stages them for commit. To unstage a file, use 'git reset HEAD YOUR-FILE'.

#----------------------------

$ git commit -m "First commit"
# Commits the tracked changes and prepares them to be pushed to a remote repository. 
#To remove this commit and modify the file, use 'git reset --soft HEAD~1' and commit and add the file again.

#----------------------------

# REMOTE-URL you found in your git ssh URL
git remote add origin REMOTE-URL

#----------------------------

# To verify that you set the remote URL correctly
git remote -v

#----------------------------

# To push
git push origin main