How to clone a local git repository to a remote server?

On the remote server:

mkdir newproject
cd newproject
git init --bare

On the local machine:

git remote add origin ssh://[email protected]/path/to/repo/newproject
git push --all origin