Push local git repo to a remote server

So this is how to put local repository onto a remote “central” version control repository:

On remote server (note the “–bare” is important otherwise you won’t be able to push):

mkdir /home/vincent/projects/repo.git
cd /home/vincent/projects/repo.git/
git init --bare

On local, cd into the local repo directory first

git remote add origin ssh://username@remoteserver/home/vincent/projects/repo.git
git push origin master

In future you can just clone:

git clone ssh://username@remoteserver/home/vincent/projects/repo.git

Leave a Reply