WHY do we need a GIT tool?

Git is a version control system that is used for tracking changes in computer files and coordinating work on those files among multiple people.

It is useful because it allows developers to keep track of the history of the code, easily collaborate with other developers, and revert to older versions of the code if needed.

Additionally, it can help teams work more efficiently by allowing them to review, discuss, and merge changes quickly and easily.

The Gitea Project

Gitea - Your own Private, Fast, Reliable Devops Platform that we will run with Docker.

SelfHosting Gitea

Enter Gitea, the tool that we are going to use, together with Docker to have Git version control.

SelfHosting Gitea

One recurrent topic that has to be addressed in the first place is how to setup docker in our machine.

Gitea Docker Stack

The configuration file that we will use today to SelfHost Gitea with Docker is:

version: "3"

networks:
  gitea:
    external: false

services:
  server:
    image: gitea/gitea:1.14.2
    container_name: gitea
    environment:
      - USER_UID=998
      - USER_GID=100
      - 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:
      - /srv/confs/gitea:/data
      - /etc/timezone:/etc/timezone:ro
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3033:3000"
      - "2234:22"
    depends_on:
      - db
 
  db:
    image: mysql
    restart: always
    environment:
      - MYSQL_ROOT_PASSWORD=gitea
      - MYSQL_USER=gitea
      - MYSQL_PASSWORD=gitea
      - MYSQL_DATABASE=gitea
    networks:
      - gitea
    volumes:
      - /srv/databases/gitea/mysql:/var/lib/mysql

You will create an user and password the first time you visit localhost:3033

Deploy with CLI

Providing that the previous steps are clear, we can jump to our terminal and use:

sudo nano docker-compose.yml

This will open a text editor, where we can paste the following configuration file:

To save, use CTRL+O, then CTRL+X to exit.

Then just deploy the service with:

sudo docker-compose up -d

You are ready to use Gitea!

The Gitea service will be running in 0.0.0.0:3033 or localhost:3033 if you use the configuration file as it is provided.

If you have deployed it in one device at home, you can use it from any other connected at the same router, just use the internal IP of the device in which you made the deployment.

Conclusion

Where is the code stored? Here: /srv/confs/gitea/git/repositories for each defined user.

sudo find /srv/confs/gitea -type d -name "repositories" #this helped :)
#sudo find /mnt/portainer_backup/srv/confs/gitea -type d -name "repositories"

To create a working copy from giteas stored files, just use the clone command: git clone path/to/gitea/git/username/reponame.git as per:

mkdir -p /mnt/external_500gb/Z_SelfH_Backup/test/gitea
cp /mnt/external_500gb/Z_SelfH_Backup/gitea/confs/git/repositories/fossengineer/py_stocks.git /mnt/external_500gb/Z_SelfH_Backup/test/gitea/.git

## All that matters are these .git files!!!!
git clone path/to/gitea/git/username/reponame.git #generate the working files as per this
#git clone /mnt/external_500gb/Z_SelfH_Backup/gitea/confs/git/repositories/fossengineer/py_stocks.git

Copy all the repositories folder to a save place:

mkdir -p /media/abc/Z_backup_cont/gitea
sudo cp -r /mnt/portainer_backup/srv/confs/gitea/git/repositories /media/abc/Z_backup_cont/gitea/

Gitea with Client GUI

How to BackUp Gitea

sudo fdisk -l #get the drive
sudo mkdir /mnt/external_500gb
sudo mount /dev/sda1 /mnt/external_500gb #mount the drive

#/mnt/external_500gb/Z_SelfH_Backup
sudo fdisk -l #get the drive
sudo mkdir /mnt/external_500gb
sudo mount /dev/sda1 /mnt/external_500gb #mount the drive

sudo mkdir -p /mnt/external_500gb/Z_SelfH_Backup/gitea/mysql/
sudo mkdir -p /mnt/external_500gb/Z_SelfH_Backup/gitea/confs/


sudo cp -r /mnt/portainer_backup/srv/databases/gitea/mysql/* /mnt/external_500gb/Z_SelfH_Backup/gitea/mysql/
sudo cp -r /mnt/portainer_backup/srv/confs/gitea/* /mnt/external_500gb/Z_SelfH_Backup/gitea/confs/

FAQ

You will need a IDE, and you can use a F/OSS version of VSCode with Flatpak:

#sudo apt install git

sudo add-apt-repository ppa:flatpak/stable
sudo apt update
sudo apt install flatpak
 
flatpak remote-add --if-not-exists flathub https://dl.flathub.org/repo/flathub.flatpakrepo 

#flatpak install flathub com.visualstudio.code
flatpak install flathub com.vscodium.codium

Or with snap:

sudo apt install snapd
#sudo snap install code --classic

Or with your WebToP or VsCode in a container:

version: "2.1"
services:
  code-server:
    image: lscr.io/linuxserver/code-server:latest
    container_name: code-server
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Paris
      #- PROXY_DOMAIN=code-server.my.domain #optional
      #- DEFAULT_WORKSPACE=/config/workspace #optional
      #- PASSWORD=password #UI Pass - optional
      #- SUDO_PASSWORD=password  #optional #IMPORTANT TO INSTALL PYTHON AND OTHERS!!
    volumes:
      - /home/Docker/vscode/config:/config
    ports:
      - 8443:8443
    restart: unless-stopped
    networks:
      nginx_nginx_network:      

networks:
  nginx_nginx_network:
    external: true    

GIT 101 Commands

How to configure GIT user and mail

git config --global user.name "Your Name"
git config --global user.email "[email protected]"

How to Login to VSCode to Github

How to use Gitea with HTTPs

If you are interested in deploying a separated NGINX instance with Docker, I already created a guide for that here.

Gitea vs Gogs vs GitLab β€” which to pick?

Gogs is the original lightweight self-hosted GIT β€” Gitea is its more actively maintained fork. GitLab is at the opposite end: full DevOps platform with built-in CI/CD, container registry, and issue tracking, but heavy on resources. Pick Gitea for a clean, fast home-lab GIT host. Pick GitLab if you actually need the integrated CI/CD and don’t mind running a 4 GB+ stack.

Does Gitea have CI/CD?

Yes β€” Gitea Actions, which speak the same workflow YAML as GitHub Actions. Add an Actions runner on a separate host (or the same one) and you can run pipelines on push without a separate CI tool. For larger pipelines, pair Gitea with Jenkins instead.

How do I run pipelines triggered by Gitea pushes?

Either Gitea Actions (built-in, GitHub-Actions compatible) or webhooks into Jenkins / n8n for custom flows. Gitea Actions is the simplest path β€” define .gitea/workflows/*.yaml in the repo and start a runner.

Can I mirror from GitHub or GitLab?

Yes β€” Gitea supports pull mirroring (Gitea pulls from an upstream repo on a schedule) and push mirroring (Gitea pushes to a remote on every commit). Useful for keeping a private clone of public code, or a public mirror of a private repo.

How do I expose Gitea safely on the internet?

Put it behind Nginx Proxy Manager for HTTPS, or expose only the SSH port and the HTTPS UI via Cloudflare Tunnel. For purely private team use, Tailscale is even simpler β€” no public exposure at all.