This is the first post in the series of how to host your own git server on a Raspberry Pi
Since its original release in 2012, Raspberry Pi has been a key companion to developers around the world for automating software tasks and building low-cost networking projects. Its capabilities have grown significantly over the years, so much so that I have started to use my Pi to self-host a git server (GitLab) at home.
I am going on a journey to document how to set up a git server with all the tools you need on Raspberry Pi, so you can do the same in 2021 and beyond. Let’s start baking our pi…
What you will need:
Raspberry Pi comes in 2, 4, and 8 GB variants in 2021. Your git server would require a version with at least 4 GB of RAM, though I do recommend to get the Raspberry Pi 8 GB to get the most performance out of your system. For the SD card, you can pick up a Samsung Evo 64GB for $10. It is best bang for your buck option on the market in 2021. You also need to get a bundle of equipment to power your Pi and protect it from dust and heat. I got this Smraza Case Bundle, which came with a power cable and active cooling fan for $15. The total cost for this system will be something around $120.
1. Download Operating System
Our first task is to download an operating system for the Raspberry Pi. We plan to use this device as a server, so we are going to look into headless options.
Raspberry Pi OS Lite and Ubuntu Server LTS are the two leading options in this space. Due to being a fast, stable and widely used 64-bit Operating System, we will use Ubuntu Server in this tutorial.
You can get a copy of the latest version here — Ubuntu Server 20.04-LTS (64-Bit). This will download a compressed image for you to use in the next step.
2. Flash SD Card Image
Now we have downloaded the OS image, our next step is to find a software tool to write this image on our SD card. Etcher is a free and portable tool that you can use for this purpose. Once you download and start the program, you will see the following screen:
Select image > Select drive > Flash!
It will take several minutes for Etcher to flash and validate all files. Once done, proceed to the next step to edit some files on the SD card.
3. Edit WiFi Credentials (Optional)
We need to edit the network configuration file to get Raspberry Pi to connect to WiFi network on its first boot. — If you are going to use an Ethernet cable to connect your Pi, you can skip this step.
Edit the ‘network-config’ file (no extension) in the SD card to look like the following, where <WIFI-SSID> and <PASSWORD> are the name (SSID) and password of the wireless network you plan to connect.
Plug the SD Card into the Pi and power it up! Your first boot will take a few minutes, which then the Pi will attempt to connect to your local network. It will show up as ubuntu in the client list (Network Map > View List) of your network router.
4. Assign Static IP
We don’t want the IP address for our Pi to change in the future as we will be using this address to connect from now on. To ensure this, we will manually assign a static ip to the Raspberry Pi by creating an entry the DHCP list (LAN > DHCP Server) of our router.
Your local static ip address range will be in the order of 192.168.X.X — You can see that I have assigned 192.168.1.2 to my PC, and 192.168.1.3 to my Pi (ubuntu).
You can also set the hostname for your devices at this step, which will allow you use a name to access your devices rather than typing the IP address. We will talk more about this in the next part of our series.
Once you are done, click Apply and give all your devices a reboot to make sure your new IP addresses fully propagate.
5. SSH into Pi
You are ready to connect your Pi! Start a secure shell connection from your computer by typing
ssh email@example.com in the terminal. Your computer might issue a warning if this is the first time connecting to this host:
The authenticity of host '192.168.1.3 (192.168.1.3)' can't be established. ECDSA key fingerprint is SHA256:<SHA-KEY>.
Are you sure you want to continue connecting (yes/no)?
yes to approve and establish the connection. You will then need to enter the password for Pi, which is
ubuntu by default.
Ubuntu will ask you to change your default password, follow the prompts as necessary. The next time you log in through ssh using the new password, your Pi will be ready to run some commands!
6. Update Pi
The first step with a new operating system is to check for stability updates. Run following commands in the same order to update and upgrade your Pi:
sudo apt update will update the package list.
sudo apt upgrade will install the packages from the updated list.
7. Set the Time Zone
You also need to adjust the timezone to your region. Timezones are listed in [Continent/City] format, such as
Europe/Istanbul. You can check the list of available timezones with
Once you find the timezone you are in, run the following command:
sudo timedatectl set-timezone <TIMEZONE>
Once you are done, you can check if the date and time are set correctly by running the
Congratulations — You have finished setting up your Pi! Next post is going to talk about creating user accounts and further customizing your Raspberry Pi.