While 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
- 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)
- 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.
- 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
- Get the updates “sudo apt-get update && sudo apt-get upgrade
- Change the hostname –
- Sudo echo “gitpi” > /etc/hostname
- sudo nano /etc/hosts (change any raspberrypi to gitpi – might not be there anymore)
- I find accessing my Pis by hostname work better on my mixed operating system network when I have Avahi running.
- 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.
- When that has completed, type: “wget http://goo.gl/P1ZyC -O setupAvahi.sh”
- chmod +x setupAvahi.sh && sudo ./setupAvahi.sh
- rm setupAvahi.sh
- rebootNow you should be able to access your Raspberry Pi from any computer on the network with the hostname “gitpi.local”.
- 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.
- First make a mount point, “mkdir /usbdrv”
- 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"
- 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
- Save and reboot.
You should now be good to go. You should be able to ‘cd /usbdrv’ and then create or clone your repos.
Comments
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!
Are you getting an error saying it cannot find / connect to the repo or invalid authentication? Can you show us your connection string?
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!”
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?
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 !
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 😉
Great guide, I really appreciated it. I could follow it from start to finish and it worked.
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?
The file “wget http://goo.gl/P1ZyC -O setupAvahi.sh” is not available anymore. Where can I find it?
Can you see this: https://gist.github.com/tagroup/73230119a9a153352296 one?