Quantcast
Channel: Thomas Loughlin » Git
Viewing all articles
Browse latest Browse all 2

GitPi: Using your Raspberry Pi as a Dedicated Git Repository

$
0
0

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.

The post GitPi: Using your Raspberry Pi as a Dedicated Git Repository appeared first on Thomas Loughlin.


Viewing all articles
Browse latest Browse all 2

Trending Articles