How to set up a local Git server on Ubuntu with Gitea

A local Git server gives a household, small team, classroom, or home lab a private place to store repositories without relying on GitHub, GitLab, or another hosted service. Gitea is a particularly good fit for Ubuntu because it is lightweight, quick to install, and provides a web interface that feels familiar to anyone who has used a modern code-hosting platform.

This setup is useful when source code, scripts, configuration files, or documentation should stay on your own network. It can also be a practical way to learn Git administration before managing a production server. An old desktop, Intel NUC, virtual machine, or quiet mini PC can all run Gitea comfortably for a small group.

Australian users should think about where the server will live. A machine in a study in Brisbane or Perth may be perfectly suitable, while a laptop that sleeps or moves between rooms will cause frustrating outages. If you are buying a low-power machine for the job, this hardware buying guide may help you compare compact systems and storage options.

This guide uses Ubuntu Server and SQLite for a straightforward private installation. SQLite is adequate for a personal server or a small number of users; PostgreSQL or MariaDB becomes a better choice as the number of repositories and accounts grows. The commands assume an Ubuntu system with sudo access and a local network connection.

Prepare Ubuntu and a fixed network address

Begin with a fresh, updated Ubuntu installation. Ubuntu Server is ideal because it does not need a graphical desktop, but Gitea also works on Ubuntu Desktop. Log in locally or through SSH, then update the package index and installed software:

sudo apt update
sudo apt full-upgrade -y

Create a dedicated system account for Gitea. Running the service as its own user limits the damage a compromised application could cause:

sudo adduser --system --group --disabled-password --shell /bin/bash git

Create the directories Gitea will use and assign ownership to that account:

sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo mkdir -p /etc/gitea
sudo chown -R git:git /var/lib/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea

A fixed local IP address is important. The simplest method is usually a DHCP reservation in your router, mapping the server’s network card to an address such as 192.168.1.50. This avoids hard-coding network settings in Ubuntu and makes the server easier to relocate. On many Australian NBN connections, your public IP can change and your provider may use CGNAT, but that does not affect access from devices inside your home.

Install Gitea and create its service

Download a current Gitea binary from the official release page, choosing the version and architecture that match your machine. Most modern Intel and AMD systems use linux-amd64; many ARM boards use linux-arm64. The following example uses placeholder version 1.22.0, so replace it with the current release before running the command:

wget -O gitea https://dl.gitea.com/gitea/1.22.0/gitea-1.22.0-linux-amd64
sudo install -m 755 gitea /usr/local/bin/gitea
rm gitea

Check that the binary runs:

gitea --version

Create a systemd unit so Gitea starts at boot and can be controlled like any other Ubuntu service:

sudo nano /etc/systemd/system/gitea.service

Add this configuration:

[Unit]
Description=Gitea
After=network.target

[Service]
RestartSec=2s
Type=simple
User=git
Group=git
WorkingDirectory=/var/lib/gitea
ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
Restart=always
Environment=USER=git HOME=/home/git GITEA_WORK_DIR=/var/lib/gitea

[Install]
WantedBy=multi-user.target

Save the file, then enable and start the service:

sudo systemctl daemon-reload
sudo systemctl enable --now gitea
sudo systemctl status gitea

If the service fails, inspect the log rather than repeatedly restarting it:

sudo journalctl -u gitea -n 50 --no-pager

The most common problems are an incorrect binary architecture, a typo in the service file, or permissions on /var/lib/gitea.

Complete the web installer

From another computer on the same network, open http://192.168.1.50:3000, replacing the address with your server’s local IP. Gitea’s first-run page asks for database, site, and administrator settings. Select SQLite3 for a small installation and use a database path such as:

/var/lib/gitea/data/gitea.db

Set the site title, server domain, and base URL carefully. For a local-only installation, the domain can be the server’s IP address or a local DNS name such as git.home.arpa. Set the SSH server port to 22 if Ubuntu’s normal SSH service is listening there. Gitea’s web port can remain 3000 during initial testing.

Create the first administrator account with a strong, unique password. Avoid reusing the password for your router, email, or NBN account. Once the setup is complete, sign in and open the administration area to review the configuration. You can edit /etc/gitea/app.ini later, but restart Gitea after changing it:

sudo systemctl restart gitea

For a small family or community project, leave registration disabled and create accounts manually. This prevents anyone who reaches the login page from creating an account. Under the administration settings, also review repository visibility, email settings, default branch names, and whether new users may create organisations.

Gitea uses SSH keys for secure Git operations. On your workstation, generate a key if you do not already have one:

ssh-keygen -t ed25519 -C "your-name@gitea"

Copy the contents of ~/.ssh/id_ed25519.pub, open your Gitea profile, choose SSH keys, and paste the public key. Never upload the private key. Test the connection with:

ssh -p 22 git@192.168.1.50

A successful response normally confirms that Gitea recognises the key, even though it does not provide an interactive shell.

Create and use your first repository

Create an empty repository in Gitea through the web interface. Give it a clear name such as home-lab-notes or website-config, and decide whether it should be private or visible to authenticated users. Do not initialise it with a README if you already have a local project containing files, because an empty remote avoids an unnecessary first merge.

Inside the existing project directory, configure your identity and add the remote:

git config --global user.name "Alex Example"
git config --global user.email "alex@example.net"

cd ~/projects/home-lab-notes
git init
git add .
git commit -m "Initial commit"
git branch -M main
git remote add origin git@192.168.1.50:alex/home-lab-notes.git
git push -u origin main

The repository address is shown on its Gitea page. Use that exact SSH address rather than guessing the username or project path. For later work, the normal cycle is simple:

git add .
git commit -m "Describe the change"
git push

To clone the project on another machine, use:

git clone git@192.168.1.50:alex/home-lab-notes.git

If SSH reports a host-key warning, check that the IP address really belongs to your Ubuntu server before accepting the new key. A connection error may instead mean that port 22 is blocked, the public key was pasted incorrectly, or the remote URL contains the wrong Gitea username.

Secure access on a home or office network

For a local Git service, limit exposure to the private network. If Ubuntu’s firewall is enabled, allow SSH and the Gitea web port from your LAN:

sudo ufw allow from 192.168.1.0/24 to any port 22 proto tcp
sudo ufw allow from 192.168.1.0/24 to any port 3000 proto tcp
sudo ufw enable
sudo ufw status

Adjust the subnet if your router uses a different range. Do not forward port 3000 from the internet merely to make Gitea accessible while you are away. An exposed, unpatched service is a poor trade-off for convenience, particularly when home routers and consumer internet plans are often configured with limited visibility and changing public addresses.

For remote access, use a VPN such as WireGuard or Tailscale, or place Gitea behind a properly configured reverse proxy with HTTPS and strong authentication. A VPN is usually easier for a small Australian home lab: connect to the private network first, then use the same internal Gitea address. This also avoids relying on whether your ISP provides a public IPv4 address. NBN upload speeds can vary widely between plans, so pushing large repositories over a remote connection may be slower than working locally.

If you use a local hostname, make sure every client can resolve it. A router DNS entry, local DNS server, or hosts-file entry can map git.home.arpa to the server’s address. The .home.arpa domain is intended for private home networks and avoids pretending that you own a public internet domain.

Back up repositories and maintain the service

A local Git server is not a backup by itself. Git stores project history, but a failed disk, stolen machine, ransomware incident, or accidental deletion can still remove the only working copy. Keep at least one additional copy on a separate disk or another trusted system. An external USB drive connected only during backup is safer than leaving every copy permanently mounted.

Gitea includes a built-in dump command that can package application data, repositories, and configuration information:

sudo -u git GITEA_WORK_DIR=/var/lib/gitea \
  gitea dump --config /etc/gitea/app.ini --file /tmp/gitea-dump.zip

Move the resulting archive to protected storage and test restoring it on a spare Ubuntu virtual machine from time to time. Also back up /etc/gitea/app.ini, because it contains important settings and may include database credentials if you later migrate away from SQLite. Never treat a backup as valid until you have successfully read or restored it.

Keep Ubuntu and Gitea updated, but take a backup before changing either. Check service health with:

systemctl is-active gitea
df -h
sudo journalctl -u gitea --since today

A small server can quietly run out of disk space when repositories contain build artefacts, virtual-machine images, or large media files. Use .gitignore to exclude generated files, and consider Git Large File Storage for genuinely large assets. For a family server in Adelaide, Canberra, or regional New South Wales, a UPS can also help protect the machine from brief power interruptions and give it time to shut down cleanly.

Once the installation works, make a note of the server’s address, administrator account, backup location, and recovery procedure. Then create one real repository, clone it from a second computer, and push a small change. The immediate next step is to reserve the Ubuntu server’s local IP address in your router and open http://server-ip:3000 to begin the Gitea setup.