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, commit code changes and merges, and allow users to clone your repositories on their own machines.
The open source ecosystem runs on Git, and many of the projects featured on MakeUseOf.com include using resources from GitHub. With Gitea, you can host your own fully functional Git repository on your own in-house Raspberry Pi.
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, isn’t a natural fit for the role of custodian. The company’s previous CEO described Linux and the General Public License as “cancer”, and most of Microsoft’s products are proprietary and closed source.
Microsoft’s ownership has also seen GitHub exploring some ethically questionable technologies – most notably with GitHub Copilot, an AI tool to help programmers generate code. CoPilot was trained on data from GitHub, in a possible violation of the terms of the Creative Commons license employed by the coders.
By using GitHub, developers are creating yet another choke point at which innovation can be stifled, undermined, and subjected to trivial interference.
You can set up your own Git server on Raspberry Pi with the help of Git
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 for a more open and faster development model than its predecessor, and will run on machines with modest resources such as the 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 DMCA takedowns, used to train nefarious software, or otherwise out of your control . ,
How to Install Gita on Your Raspberry Pi
Gitea comes with several installation methods, but the easiest 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 on your Gitea server will potentially take up a lot of space, so we recommend that you use external storage with your Raspberry Pi, and use this as the location for your Gitea install .
Don’t change anything now. If you plan to access your Gita instance over the Internet, you’ll need to do a little more preparation first.
Access your Gita instance over the Internet
You want to be able to type in a standard URL to be able to access your Gitea instance, so you’ll need Apache to handle the proxying.
Choose a domain name or subdomain name from a reputable registrar. Then, from your registrar’s settings page, find the ‘Advanced DNS’ option and add a new A record. Set the Host field to “@” and the Value field to your static IP address. Set the TTL (Time to Lease) value as low as possible, then save.
Open your router admin page, and find a section titled Port Forwarding, Port Mapping, or Port Management.
Create a new entry for HTTP requests. Set both the local and public port to 80, and set the local IP address to your Raspberry Pi’s IP address.
HTTPS requests require a second open port. Set both the local and public ports to 443, and again, set the local IP address to your Pi’s IP address.
Finally, you need to open a port on your Git server for SSH requests. Set both the local and public ports to 222, and set the local IP address to your Pi’s IP address.
You would use Certbot to obtain the security certificates and keys.
Gita instance setup
You can now visit your Gitea instance in a browser with the address https://your-domain-name.tld. You will be able to set the database type, password, and other variables in the first section. These will be the values you specified in your docker-compose file, and should already be filled in, so there’s no need to change them.
In General Settings, set the Site Title to an appropriate one, Server Domain should be your domain name and SSH Server Port should be set to 222. Base URL should be your domain name including “HTTPS://”.
When you’re done, hit the big blue Install Geeta button. You’ll be greeted with a big green cup of tea, and whatever name and slug you’ve given for example. To create your first user, click Register at the top right of the page, then enter your details. Congratulations!
To prevent anyone else from registering and hosting their own repository on your Git server, you need to edit the app.ini file.