create remote repository from local code example

Example 1: initialize a repo and push to github

git init
git add -A
git commit -m 'Added my project'
git remote add origin git@github.com:sammy/my-new-project.git
git push -u -f origin master

Example 2: create a git repository from local machine and push it online

#initialize 
git init 
# add your URL , it can be local or remote one 
git remote add origin <YOUR_URL>
# commit something
git add *
git commit -m "your message"
# push to your repository 
git push origin master
# you can then go and check online