how to push an existing git repository to remote code example

Example 1: git push new repo to remote

$ git remote add origin <remote repository URL>
# Sets the new remote

# Push the changes in your local repository to GitHub.
$ git push -u origin master
# Pushes the changes in your local repository up to the remote repository you specified as the origin

Example 2: git push existing git repository

cd myapp
git remote rename origin old-origin
git remote add origin https://github.com/myname/myapp.git
git push -u origin --all
git push -u origin --tags