Raspberry Pi GIT Server Notes

Edit: I updated my RP GIT server and made more notes in a later article.

Here are my notes for setting up GIT on Raspberry Pi and using a Windows client (TortoiseGit). I’ve been using this little thing as a GIT server for around 5 months now and I love it. Here is the quick notes I took while getting things setup. It’s probably really disjointed, but you might find some helpful tips in here.

Install Raspbian (GIT seemed to be pre-installed on the version I used):
The defaults:
username: pi
password: raspberry

When greeted with the post install program, find the advanced option to enable SSH. You can also change your password from there.

2017 Edit: I’m in the process of installing it on a larger SD card. Anything over 32GB will probably require an extra formatting step detailed here. The current install takes the user directly to the GUI operating system after it is finished setting things up. You need to go into the start (raspberry) button >> “Preferences” >> “Raspberry Pi Configuration” to find options. From there you can switch it up to boot from the command line instead of the GUI.

Once you are at a command prompt you can do this to enable SSH:

  • Enter sudo raspi-config in a terminal window
  • Select Interfacing Options
  • Navigate to and select SSH
  • Choose Yes
  • Select Ok
  • Choose Finish

Once you are setup, you can slim down what NOOBS pre-installs into the OS thanks to this person who made this script.

Download PuTTY for SSH (used for the remote command line interface):
A Windows installer for everything except PuTTYtel

Download and install Window GIT:

Download and install Tortoise GIT:

Linking RP and your client with source code:
Create the local repository by adding a folder to your computer and right-clicking on it and selecting “Git create repository here…” from the context menu.

Generate your SSH keys:
Use Puttygen to make the keys, save both the public and private keys. Name the private key with a .ppk extension.
Seems to be optional if you do everything on the same local network.

SSH to your pi

# 1. Install Git
sudo apt-get install git git-core

# 2. Add a system user named 'git'
sudo adduser --system --shell /bin/bash --gecos 'git version control by pi' --group --home /home/git git

# 3. Set the password for the new user 'git'
sudo passwd git

# 4. Switch to the 'git' user to create an empty repository
su git

# 5. Create a directory for the Git repository (example: repo.git)
cd /home/git
mkdir repo.git
cd repo.git

# 6. Initialize a bare Git repository
git --bare init

Back to your working machine where you have a folder you want to push to the new GIT server:
You can use TortoiseGit to set things up.
Right-click on the main folder. Select Git Create Repository here.
Right-click >> TortoiseGIT >> Settings >> Remote…
From there you can add server details.
Remote: A name you want to call it.
URL: something like git@X.X.X.X:repo.git
Where X.X.X.X would be the IP address of the new server on your local network.
The Push URL is the same as the URL.
All of the other options can be left default unless you made a Putty Key earlier.


TortoiseGit settings:
Settings >> Git
Select Global so you can edit the User Info fields
Name: git
Email: none

Select something like “Git Sync…” when right-clicking on your repo.
Remote URL input, click the “Manage” button
Remote: a name like “RaspGIT”
URL = git@
Putty key: the private key you made before


I have the RP setup with two USB thumb drives as backup. Right now they are setup as RAID 1 and get updated with a program called Unison.

RAID 1 on RP device:

sudo apt-get install hdparm lvm2 mdadm
sudo fdisk -l
df -h
sudo mount -l
sudo mkfs.ntfs /dev/sda1 -f -v -I -L untitled


mdadm –create /dev/md0 –level=1 –raid-devices=2 –force /dev/sda /dev/sdb
apt-get install dosfstools
mkdosfs -F 32 -I /dev/md0
sudo fdisk -l
hdparm -t /dev/md0 (test the speed)
pi@raspgit /etc/mdadm $ sudo mdadm –detail –scan
ARRAY /dev/md0 metadata=1.2 name=raspgit:0 UUID=00000000:00000000:00000000:00000000
sudo pico /etc/mdadm/mdadm.conf

That should be it for it to auto initialize and run…


sudo apt-get install unison

pico /etc/fstab
*** Add the below line:
/dev/md0 /media/raid auto defaults 0 0



cat /proc/mdstat
sudo mdadm –detail /dev/md0


ls -a (show hidden directories)
unison -ui text -auto default.prf


touch ~/.unison/unison.prf
pico ~/.unison/unison.prf
# Unison preferences file
# For local synchronisation:
# Roots of the synchronization:
root = /home/git
root = /media/raid1/git
perms = 0
dontchmod = true
ignorecase = true
links = false
ignoreinodenumbers = true
# Some regexps specifying names and paths to ignore
ignore = Name temp.*
ignore = Name *~
ignore = Name .*~
ignore = Path */pilot/backup/Archive_*
ignore = Name *.o
ignore = Name *.tmp





force = /home/git




0 19 * * * /usr/bin/unison [options]
crontab -u USERNAME cronjobs.txt
crontab -l
unison for -batch, ask no questions
crontab -e
30 * * * * /usr/bin/unison -batch “default” >> /home/pi/unison.log

To view mail from crontab:

cat /var/spool/mail/pi

Recovery from a live cd:

sudo apt-get install mdadm
sudo mdadm –assemble –scan

That’s everything so far. Though, what I need to do is make a backup of the OS SD card, but I haven’t done that.