If you have a local repository and want to create your own remote git repository as a backup (or share your work with others, here’s what you need to do:

On the remote server:

Create a directory in the remote server that will contain the repository

mkdir /home/projects/myapp
cd /home/projects/myapp

Initialize an empty Git repository in the directory created in the previous step

git --bare init

On the local computer:

Go to the directory where the repository is located

cd /home/user1/myapp

Add the remote repository to the local git repository (we name it ‘origin’)

git remote add origin ssh://<user>@<server>/home/projects/myapp

Copy the contents of the master branch of the local repository to the remote server

git push origin master 

Now the remote repository is ready; any other people can use the repository using:

git clone ssh://<user>@<server>/home/projects/myapp
Share!