Skip to main content

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):
http://www.putty.org/
A Windows installer for everything except PuTTYtel

Download and install Window GIT:
https://git-for-windows.github.io/

Download and install Tortoise GIT:
https://tortoisegit.org/

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@192.168.0.10:repo.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:
http://blog.drewwithers.com/2013/11/raspberry-pi-usb-raid1-root-partition.html
http://jeddi.org/b/2013/08/26/crypted-raid5-usb-on-raspberry-pi/


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


http://linuxconfig.org/linux-software-raid-1-setup
http://www.howtoforge.com/software-raid1-grub-boot-debian-etch
http://www.howtoforge.com/how-to-set-up-software-raid1-on-a-running-system-incl-grub2-configuration-debian-squeeze-p2
http://ubuntuforums.org/showthread.php?t=884556


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
http://fabianpeter.de/cloud/hybrid-cloud-with-unison-and-owncloud/
http://fabianpeter.de/in-a-nutshell/run-raspbian-from-usb-stick/
http://peter-butkovic.blogspot.com/2013/08/raspberry-pi-driven-dropbox-alternative.html
http://www.markus-gattol.name/ws/unison.html

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

http://askubuntu.com/questions/113733/how-do-i-correctly-mount-a-ntfs-partition-in-etc-fstab
http://raspberrywebserver.com/serveradmin/connect-your-raspberry-pi-to-a-USB-hard-disk.html

Status:

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

http://www.granneman.com/techinfo/security/backup/unisonbackup/

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


—————————————————————–

http://www.howtoforge.com/setting-up-unison-file-synchronization-between-two-servers-on-debian-squeeze

http://xmodulo.com/2013/09/synchronize-files-between-two-servers.html

http://www.jacobbudin.com/2013/09/an-introduction-to-file-synchronization-with-unison/

force = /home/git

http://www.pgbovine.net/unison_guide.htm
http://www.pgbovine.net/unison-for-your-mom.htm
http://www.answeredubuntu.com/109488/how_can_i_run_this_script_on_startup_restart_and_shutdown#sthash.ggon19H3.dpbs

———————————————————-

http://caseonetech.com/blog/unison-server
http://ubuntuforums.org/showthread.php?t=869219

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:
http://askubuntu.com/questions/15933/how-to-access-md-raid-via-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.

Popular posts from this blog

ChatGPT is a new, and faster, way to do programming!

Currently ChatGPT is in a free “initial research preview” . One of its well known use cases at this point is generating software code. I’ve also just used it to write most of this article… Well, actually a future article about cleaning up SRT subtitle files of their metadata faster than I have been by hand with Notepad++ and its replace functionality. Update: I recorded a screencast of writing the SRT subtitle cleaner application loading and processing portion. I relied heavily on ChatGPT for code. It was a fun process! https://youtu.be/TkEW39OloUA ChatGPT, developed by OpenAI, is a powerful language model that can assist developers in a variety of tasks, including natural language processing and text generation. One such task that ChatGPT can help with is creating an SRT cleaner program. SRT, or SubRip Subtitle, files are commonly used to add subtitles to video files. However, these files can become cluttered with unnecessary information, such as timing lines or blank spaces. To clean...

Theme error in 2010s Android App after AppCompat Migration

I plan on releasing a lot of my old work as GPL open source, but most of it has aged to the point that it no longer functions, or if it does work it’s running in compatibility mode. Basically it’s no longer best practices. Not a good way to start off any new public GPL projects, in my opinion. The current project I’m working on is an Android app that calculates star trails meant to help photographers get or avoid that in their night time photos. For now I’m going to skip some of the import process because I didn’t document it exactly. It’s been mostly trial and error as I poke around Android Studio post import. The Android Studio import process… Removing Admob Google Play code before the project would run at all. After removing dependencies, it kind of worked, but when running it in the emulator it shows a pop-up message saying that the app was developed for an old version of Android. Going through the process of updating code to match current best practices… I had the IDE convert the ...

Blogger Notable theme pop-up header issue fix (thanks to Gemini Pro)

I've made a few half hearted attempts over the years to to fix Blogger's Notable theme's rendering of the pop-up header that shows up when you scroll down the page a decent amount and then pull back to reveal that secondary header. On Chrome mobile I noticed a gray box that forms next to the magnifying glass icon. I never looked in detail on  Chrome desktop, but it had an issue as well which I'll detail below.  If you are looking for a solution and don't want all of the extra talk about how I was able to find it, here it is:  .centered-top-container .sticky .main_header_elements { overflow : hidden !important ; } I decided to try using Gemini Pro 2.5 to see if it was capable of finding the issue and giving me a fix. Turns out that it was able, but it took a bit of collaboration back and forth to find the actual problem.  Here is a modified article I asked it to give me based on our debugging chat (it was very colorful in the article which I scaled back a lot, ...