I manage my code on a local git repository on my desktop. But I want to access the git repository also from my local laptop or via VPN from remote. This requirement needs to convert the local repository into a remote repository. I'm running a Raspberry as my LAN server which is online all the day and is a perfect git server.

There are a lot of articles in the net how to achieve this. Finally I managed to find my way to get it done. It's not difficult but you have to know what you have to do.


Move of a local git repository to a remote git server

First of all the .git directory of the local repository has to be tared.

cd /home/framp/raspiBackup/.git 

tar -pcf ../raspiBackup.tar *

Now create on the git server (raspifix is my server) a directory /home/framp/git/raspiBackup.git and untar the git repository

tar -xf raspiBackup.tar *

Next step is to change the git repository into a bare repository.

git config --bool core.bare true

and now the remote repository is ready to be used.

It may be useful to save the current local repository just in case.

mv /home/framp/raspiBackup /home/framp/raspiBackup_local

Now create a new repository on your local system which connects to the remote repository

cd /home/framp
git clone framp@raspifix:/home/framp/raspiBackup

Now you have to copy your public key ~/.ssh/id_rsa.pubto the server. If ther is no public key already generate its with no passphrase (otherwise you have to configure and use the ssh-agent which is overkill in a local network.


and now copy the key

ssh-copy-id framp@raspifix

to the server. Finally adjust your config files in the .git directory.

Now enjoy to share the code between different clients.


Define a dedicated user for the remote git repository

sudo adduser git
su git
mkdir .ssh

Now disable remote access to git via ssh.  Edit /etc/passwd and change the line




Now every user who should be able to acces the remote git has to pass its ssh key ~./ssh/ir_rsa.pub to the server administrator which appends the key as user git to /home/git/.ssh/authorized_keys.

Now every user can acces the reote repository (Us user git instead of framp now)

cd /home/framp
git clone git@raspifix:/home/git/raspiBackup

Now enjoy to share the code between different clients.


There is another appoache to use Linux groups to grant acces to the git (e.g.. development group). See the following links for details on this.



How To Create a Remote Shared Git Repository

Git Website

Git Reference

Add comment

Spam Kommentare sind sinnlos !
Vor der Publizierung wird jeder Beitrag auf Spam geprüft. Leider dauert es deswegen bis ein Kommentar sichtbar wird. Dafür erhält aber kein Subscriber Spam eMails.
Die eMail ist optional und nicht öffentlich sichtbar. Sie ist notwendig um eMail Benachrichtigungen zu Antworten auf Kommentare zu erhalten. Sie wird auch u.U. auch vom Seitenbetreiber genutzt um offline Kontakt aufzunehmen.

Spam comments are useless !
Any comment will be reviewed first and checked for spam. Unfortunately this delays the publishing of comments but will protect subscribers from spam.
eMail is optional and hidden and is required to get update notifications for any comments. In addition your eMail may be used by the website owner to get in contact with you offline.