Setup a remote git repository on a server

November 23, 2012

This Blogpost shows you, how you can create a remote git repository on your own server, to collaborate with other people through this server.

install the following package to asteblish a secure connection for your remote git repo

be sure that git is installed on your server

if not installed you can install it simply by typing:

go to the server directory that you want to use as a remote repository (for example /var/www/rails/PROJECTNAME/gitrepo ) and type the following to initialize your remote repository.

the following command can check the users who are present on your system

you should find a entry with the user git that can look like the example below
git:x:107:116:git version control,,,:/home/git:/bin/sh

go to your local repository (cd /var/www/rails) and create a local repository

you have to create some files before you can push something to the server and add them to your repo

commit changes

add your server repository as remote repository to your local one

if something went wrong with your configuration for the local repository
you can eigther delete the local .git directory and do git init again
or you can go into your local repository and edit the config file

create a rsa public and a private key
check if the directory ~/.ssh exists
if not create it:

if you don’t have a ssh key
you have to generate your ssh key by typing:

NOTICE: You don’t have to enter a file name you can press return. Than you have to enter a passphrase and repeat it.

after that you have to add your local rsa-key to the server, because if you don’t you will be asked for the password of the user git. But because your user git don’t have any password and you don’t want to type a password everytime when you push to the server, you add the rsa-key.

now you are ready to push your first files
NOTICE: you can’t push empty directories you have to add a file like the README above!

Tags: , ,

Leave a Comment

You must be logged in to post a comment.