Use a Raspberry Pi to host your own independent Git server for code repositories. front page of a self-hosted gitea instance.
Git is a version control system used by software developers, coders, and tinkerers to collaborate on and distribute open source projects. Using Git, you can handle projects of any size, pull in code changes and merges, and allow users to clone your repositories onto their own machines. The open source ecosystem runs on Git, and many of the projects featured on MakeUseOf.com involve using resources from GitHub. With Gitea, you can host your own fully functional Git repositories on a Raspberry Pi in your own home.
Why Host Your Own Git Service on Raspberry Pi Instead of Using GitHub?
With 55 million users, GitHub is the largest repository of free and open source software on Earth, but its current owner, Microsoft, is not a natural fit for the role of custodian. Previous CEOs of the company described Linux and the General Public License as “a cancer”, and most of Microsoft’s own products are proprietary and closed source.
Microsoft’s ownership has also seen GitHub exploring some ethically dubious technologies—notably with GitHub Copilot, an AI tool to help programmers to generate code. Copilot was trained on data from GitHub, in possible violation of the terms of the Creative Commons licenses employed by coders.
By using GitHub, developers are creating yet another choke point at which innovation can be stifled, undermined, and subjected to frivolous interference.
Gitea Lets You Set Up Your Own Git Server on Raspberry Pi
Gitea is a fork of Gogs, and is a community-managed lightweight code hosting solution written in Go, and published under the MIT license. It aims to have a more open and faster development model than its predecessor, and will run on machines with even modest resources, such as a Raspberry Pi. You’ll be able to work on your dotfiles, custom Ubuntu ISOs, Bash scripts, and Java and Python utilities without fear that they’ll be subject to a DMCA takedown, be used to train nefarious software, or be otherwise out of your control.
How to Install Gitea on Your Raspberry Pi
Gitea comes with several installation methods, but the easiest one is via Docker. If you don’t have these already running on your Raspberry Pi, install Docker and Docker Compose now.
The files you store in your Gitea server will potentially take up a lot of space, so we suggest using external storage with your Raspberry Pi, and using that as the location for your Gitea install.
Connect to your Pi via SSH, then navigate to the location where you want to install Gitea, and create a new directory, then move into it:
mkdir giteacd gitea
Create a new file with nano:
…and paste the following code into it:
version: "3"networks:  gitea:    external: falseservices:  server:    image: gitea/gitea:latest    container_name: gitea    environment:      - USER_UID=1000      - USER_GID=1000      - GITEA__database__DB_TYPE=mysql      - GITEA__database__HOST=db:3306      - GITEA__database__NAME=gitea      - GITEA__database__USER=gitea      - GITEA__database__PASSWD=gitea    restart: always    networks:      - gitea    volumes:      - ./gitea:/data      - /etc/timezone:/etc/timezone:gb      - /etc/localtime:/etc/localtime:gb    ports:      - "3000:3000"      - "222:22"    depends_on:      - db  db:    image: mysql:8    restart: always    environment:      - MYSQL_ROOT_PASSWORD=gitea      - MYSQL_USER=gitea      - MYSQL_PASSWORD=gitea      - MYSQL_DATABASE=gitea    networks:      - gitea    volumes:      - ./mysql:/var/lib/mysql
Change the timezones to your own locale and choose a strong password for your database, then save and exit nano with Ctrl + O, then Ctrl + X.
docker-compose up -d
…to bring up docker-compose in detached mode. Docker-compose will pull multiple images for Gitea and Maria DB and set up containers. Depending on your connection speed, this may take some time.
When you are returned to the command prompt:
…should show “gitea” and “gitea_db_1” as “up”. You can now visit the initial configuration page for your Gitea site at your.pi.local.ip.address:3000.
Don’t alter anything yet. If you’re planning to access your Gitea instance over the internet, you need to do a little more preparation first.