Raspberry Pi being used as a Git RepoWhile this setup is extremely quick, but as a programmer, it is one of my favorite uses for the Raspberry Pi.  I have to admit that it makes life so much easier for me that I keep a dedicated Pi just for the purpose of keeping my private projects, deployments, and backups in sync.

Required Materials

  1. Raspberry Pi – 256mb model works great.  Really unless you are using it for large projects with lots of commits, this headless server would be overkill on the 512mb Rev b (use that one for RaspBMC)
  2. SD Card with the latests Wheezy Rasbian Distro.  The size and the class of the card are not super important since your repos will actually live on item 3 but these class 10 cards are pretty cheap from Amazon.
  3. USB Jump Drive or external hard drive – only you know what you are wanting to save so you have to pick the size.  Note – with some usb flash drives and a lot of external hard drives, you will want to use a self powered hub.

Why not use a big SD card and forget the hassles of another storage device and possibly a hub?  You can – I like to separate the Git files to a device / partition that is easily readable on my other computers in case of failure.  If Pi dies, I just plug it in to my Mac or Windows machine and ‘GIT’ back to work.

Setup of your GitPi

  1. Get the updates “sudo apt-get update && sudo apt-get upgrade
  2. Change the hostname –
    1. Sudo echo “gitpi” > /etc/hostname
    2. sudo nano /etc/hosts (change any raspberrypi to gitpi – might not be there anymore)
    3. I find accessing my Pis  by hostname work better on my mixed operating system network when I have Avahi running.
      1. To download the quick installation script, run ‘sudo apt-get install wget git-core’.  This step also takes care of getting the Git server and client software.
      2. When that has completed, type: “wget http://goo.gl/P1ZyC -O setupAvahi.sh”
      3. chmod +x setupAvahi.sh && sudo ./setupAvahi.sh
      4. rm setupAvahi.sh
      5. rebootNow you should be able to access your Raspberry Pi from any computer on the network with the hostname “gitpi.local”.
  3. Now it is time to mount the drive.  We are going to set it up so it automatically mounts every time we start the GitPi.
    1. First make a mount point, “mkdir /usbdrv”
    2. Now we have to get some information about the drive with “sudo blkid”My output looks like this for my usb drive:
      /dev/sda1: LABEL="Lexar" UUID="71A3-E047" TYPE="vfat"
    3. My jump drive has type “vfat”.   Some of you will see “NTFS”; in which case, you would replace vfat with ntfs-3g in the line we are adding to fstab.  I have to give you a warning here.  If you mess up your fstab file, you are going to have problems so make a backup (really not a big deal since we are doing this with a fresh disk image). So now the editing: ‘sudo nano /etc/fstab’ and add the following line to the bottom of your fstab with the appropriate uuid and type values (the entire bit below should go on one line).
      UUID="71A3-E047" /usbdrv         vfat    uid=pi,gid=pi,umask=0022,sync,auto,nosuid,rw,nouser 0           0
    4. Save and reboot.


You should now be good to go.  You should be able to ‘cd /usbdrv’ and then create or clone your repos.


  1. jimmy white -

    i finally have this working, together with gitweb, however, Im struggling to connect my ide (Xcode) to my repository – there seems to be little in the way of documentation on how to connect – either that, or I am missing the obvious!

    • Thomas -

      Are you getting an error saying it cannot find / connect to the repo or invalid authentication? Can you show us your connection string?

  2. Flemming Munk -

    I get this error in the “git bash” CLI on win7:
    fatal: Not a git repository (or anu of parent directories): .git
    when i try the command:
    git remote add origin [email protected]:myrepo.git

    For some reason i can not see the gitpy server on the the network!?
    – i can login to the gitpy server using putty and the ip address tho’

    … as jimmy white writes “there seems to be little in the way of documentation on how to connect – either that, or I am missing the obvious!”

    • Thomas -

      Couple questions to start (sorry if these seem silly):

      1. Will it work with git remote add origin [email protected]:myrepo.git? (we can then troubleshoot Avahi)
      2. Just to make sure – myrepo.git was initialized and you can clone it locally?

      • Flemming Munk -

        Thankyou Thomas for a quick reply – no questions are silly in my world, only silly answers are possible 😉

        It turns out that installing samba on the gitpi server solved all problems… after that everything performs as expected.

        I guess that answers your two questions too 🙂

        Thankyou for a nice guide/idea – it is awesome what this little computer can be used as !

  3. jimmy white -

    the connection string i uss is
    http://[email protected](url of pi)/projects/project.git
    I get the error (from xcode)
    fatal: http://[email protected](url of pi)/projects/project.git/info/refs?service=git-upload-pack not found: did you run git update-server-info on the server?
    (I did 😉 )
    if i try via ssh i get a slightly different error after authenticating
    fatal: “/projects/project.git” does not appear to be a git repository
    fatal: could not read from the remote repository
    Please make sure you have the correct access rights and the repository exists.

    I can see the project it gitweb (it’s actually a clone of a project I have in bitbucket at the moment)

    This is a great little tutorial by the way, appreciate you helping me with my learning curve 😉

  4. aesbjorn -

    Great guide, I really appreciated it. I could follow it from start to finish and it worked.

  5. KK_Rspi -

    Hello Guys,
    i just tried this, all setting up and installing git-core is fine, but i cannot browse my gitpi using https://gitpi.local
    any suggessions?

  6. nickmicksoares -

    The file “wget http://goo.gl/P1ZyC -O setupAvahi.sh” is not available anymore. Where can I find it?


Leave a Reply