Setup Your Own Git Server on RaspberryPi

To setup a local git server on a RaspberryPi, the procedure is actually very simple.

You need following things configured on the system on which you are setting up the git server.

  • SSH needs to be enabled.
  • git-core needs to be installed.
  • git repo needs to be initialized. This repo will be cloned and mentained.

Enable SSH on RaspberryPi

Add following line to /etc/rc.local before exit 0.

sudo /etc/init.d/ssh start

This will start the ssh daemon on your device once it is started and you will be able to log in to the device over ssh.

Install git-core

Following command will install git core on the raspberrypi(raspbian).

$ sudo apt-get install git-core

Initialize the git repo

create a directory for repositories and initialize a git repo in that.

$ mkdir git
$ mkdir git/hello.git
$ cd git/hello.git

To initialize the git repo.

$ git init --bare

Use the git repo

Once this is done; you are good to go. Now you can clone the repo using following command.

git clone pi@raspberrypi.local:/home/pi/git/hello.git 

If you need to add a remote to your existing repo.

 git remote add pi pi@raspberrypi.local:/home/pi/git/hello.git 
comments powered by Disqus