Tested on:Raspberry Pi 2; Raspberry Pi B+; Python 2.7; Raspbian pre Jessie
Prerequisites:Raspberry Pi with Raspbian Jessie and internet connection (see steps 1-7 in the Introduction)

Arrr, my treasure! A private Raspberry Pi Git Repository

Sharing code on GitHub is great, but not all projects are meant to be shared publicly. Private GitHub repositories cost money; instead, it’s quite easy to setup a private Git repository for Raspberry Pi projects on a USB stick(git is the version management software GitHub runs on). When the code should go public, uploading it onto GitHub could be done by switching repositories.

A tribute to Scott Kildall for his very precise and informative instructable! With his instructions for a private Git Server, the workflow proposed in the advanced setup with the scp plugin for Sublime Text 3 could be improved: The scp plugin can be modified for executing a push on the host instead and then be pulled and executed in an ssh terminal on the Raspberry Pi.

Install Git
Enter in the terminal of both the host machine and the Raspberry Pi

Plug an USB stick into the host machine, format it as FAT and name it GITREP.

Create a mount point
Turn off the Raspberry Pi, insert the USB stick and turn it on again. Type in the Raspberry Pis terminal

This lists a device with the ID GITREP and /dev/sda1 in front of it.
Open fstab with sudo nano /etc/fstab and add at the end of the file and in one line

Save, then reboot the Raspberry Pi.

Test the mounted device
Test the mounted device by creating a file test.txt on it: sudo nano usbdrive/test.txt. If it’s possible to write into the file and save it, everything is alright.

Create an empty repository
Now, lets create an empty repository on the Raspberry Pi by typing

Prepare the project on the host machine
Replace RASPIIP with the IP of the Raspberry Pi in the local network and type in the hosts terminal

to download and setup the sample project for git.

Commit the project
In the hosts terminal, type

Repeat these last two steps with a short description of the changes as commit message whenever the project was modified on the host and should be run on the Raspberry Pi.

Pull and start the project
First, the repository needs to be cloned by entering

in the Raspberry Pis terminal. After every push on the host machine, pull the repository on the Raspberry Pi and execute the script with

Publish the repository on GitHub(optional)
On the host machine, change USERNAME to a GitHub username in

Add, commit & push then.

Here is some more info on GitHub and git usage: Manage projects with GitHub.

GitHub introduction: http://www.knight-of-pi.org/manage-raspberry-pi-python-projects-on-github/
Git Website: http://git-scm.com/
Scott Kildall - Private Git repository instructable: http://www.instructables.com/id/GitPi-A-Private-Git-Server-on-Raspberry-Pi/
Advanced setup tutorial: http://www.knight-of-pi.org/workflow-advanced-raspberry-setup/
Sublime Text 3 scp plugin: http://www.knight-of-pi.org/using-a-host-computer-for-coding-on-the-raspberry-pi
Sublime Text 3 configuration: http://www.knight-of-pi.org/basic-sublime-text-3-configuration/
Remote access with SSH: http://www.knight-of-pi.org/remote-control-your-raspberry-pi/
Angry IP Scanner usage: http://www.knight-of-pi.org/sniff-a-raspberry-angry-ip-scanner
Standard Python project structure: http://www.knight-of-pi.org/standard-python-project-file-setup/

Knight of Pi

Johannes Bergs aka Knight of Pi. Diploma in Bioinformatics, some Webdesign and Python coding then. Living in the beautiful city of Vienna.


  1. This is great!

    There’s also no need to remove the pi remote from your host machine at the end — in fact it is still useful to keep it around so that you can push to the Pi without going via GitHub (or wherever you set the origin).

    The only occasion to remove the pi remote might be if RASPIIP changes (can happen if you’re letting your local network allocate IPs with DHCP). But in that case you might better just do this on the host computer (afer learning the NEWRASPIIP):

    git remote set-url pi pi@NEWRASPIIP:/home/pi/usbdrv/MyProject.git

    • Hey Mike,
      yes, you can keep several remotes, but i mostly prefer to have just one, so i do not get confused and push to the wrong remote accidently.
      As of now, i’m using a directory on my disk for public and private git repos:
      Private repos are pushed to a subdirectory, public ones to GitHub. Works like a charm so far.

      So long,


Time limit is exhausted. Please reload CAPTCHA.