KOPPLA
0/71

Article 001.300.222 · Private Git workshop

KOPPLA

Assemble a free Git server on Ubuntu with Forgejo, then connect three Windows computers. Check a box when that piece is on.

Time
45–90 min
People
1
Machines
1 + 3
Difficulty
■■□□□
0

Parts in the carton

Gather these before you start · 2 min

Nothing here is paid software. Forgejo, Docker, and Git are free.

01

One Ubuntu computer

This is the host. It only needs to be on when you want to sync. A spare laptop or mini PC is enough.

02

Three Windows computers

Desktops or laptops on the same home network as Ubuntu.

03

The same Wi-Fi or wired network

Forgejo will live on your LAN. You do not need to expose it to the internet.

04

An Ubuntu account that can use sudo

You will type a few terminal commands. Copy them exactly.

05

Git for Windows installer

Download from git-scm.com on each Windows PC. Free. Keep the default options.

06

Optional: a Microsoft account for OneDrive

Only if you want a cloud copy of the server data as a spare tire.

A

Build the Ubuntu server

On the Ubuntu computer only · 25–40 min

Install Forgejo — a free, lightweight Git workshop that looks and acts like GitHub, but it lives in your house.

01

Open Terminal

Press Ctrl + Alt + T, or search for Terminal in the Ubuntu menu. Leave this window open for the rest of section A.

02

Update the system

Paste this, press Enter, then type your password if asked. Wait until it finishes.

copy this exactly
sudo apt update && sudo apt upgrade -y
03

Install Docker

This is the free engine that will run Forgejo in a box so the rest of Ubuntu stays clean.

copy this exactly
sudo apt install -y docker.io docker-compose-plugin git curl
04

Turn Docker on so it starts with the computer

copy this exactly
sudo systemctl enable --now docker
05

Add yourself to the docker group

Without this, every Docker command would ask for sudo.

copy this exactly
sudo usermod -aG docker $USER
06

Log out of Ubuntu, then log back in

The group change only takes effect after a new login. Close Terminal, sign out, sign in, then open Terminal again.

Caution. If you skip this, the next Docker commands will say permission denied.

07

Make a folder for Forgejo

copy this exactly
mkdir -p ~/forgejo && cd ~/forgejo
08

Create the recipe file

This file tells Docker what to run. Open the file, paste the block below, save, and close. SQLite is built in — you do not need a separate database for a home setup.

copy this exactly
nano ~/forgejo/docker-compose.yml
~/forgejo/docker-compose.yml
networks:
  forgejo:
    external: false

services:
  server:
    image: codeberg.org/forgejo/forgejo:16
    container_name: forgejo
    environment:
      - USER_UID=1000
      - USER_GID=1000
    restart: always
    networks:
      - forgejo
    volumes:
      - ./data:/data
      - /etc/localtime:/etc/localtime:ro
    ports:
      - "3000:3000"
      - "222:22"
09

Start Forgejo

The first start downloads the image. Give it a minute.

copy this exactly
cd ~/forgejo && docker compose up -d
10

Confirm it is running

You should see a container named forgejo with status Up.

copy this exactly
docker ps
11

Write down the Ubuntu IP address

The first number is usually the one the Windows PCs will use. Example: 192.168.1.42. Write it on paper. You will need it in every later section.

copy this exactly
hostname -I | awk '{print $1}'

Note. If the address starts with 172. and you also have a 192.168. number, use the 192.168. one.

12

Open the door on the firewall, if you use one

Skip this if ufw is not active. If you are not sure, run the status command first.

copy this exactly
sudo ufw status
sudo ufw allow 3000/tcp
sudo ufw allow 222/tcp
13

Open the installer in a browser

On Ubuntu, visit http://localhost:3000. From a Windows PC on the same network, visit http://YOUR-IP:3000 (use the IP from the previous step).

14

Choose SQLite3 as the database

One file. No extra service. Perfect for a household workshop.

15

Fill in the site address

Server Domain: YOUR-IP (just the numbers, no http). SSH Port: 222. HTTP Port: 3000. Forgejo Base URL: http://YOUR-IP:3000/

Caution. If you later give the Ubuntu machine a new IP, you will need to update this Base URL in Forgejo site settings.

16

Create the first administrator account

Pick a username, email, and a password you will remember. This is the key to the workshop. Write it down.

17

Press Install Forgejo and wait

When it finishes you will land on the sign-in page. Sign in with the admin account you just made.

18

Create your first repository

Click the + in the top right, then New Repository. Give it a short name, for example family-notes. Tick Initialize repository if you want a README to start with. Create.

19

Copy the HTTP clone address

On the repo page, click HTTPS. Copy the URL. It looks like http://YOUR-IP:3000/yourusername/family-notes.git. You will paste this on each Windows PC.

B

Connect each Windows computer

Repeat on Windows PC 1, then 2, then 3 · 10–15 min per PC

Each Windows machine gets its own local copy of the repo. Use the tabs below and finish one computer before you start the next.

01

Download Git for Windows

On that PC, open a browser and go to git-scm.com. Download the Windows installer. Run it.

02

Install with the recommended options

When asked, choose Git from the command line and also from 3rd-party software. Leave the rest on defaults. Finish and close the installer.

03

Open Git Bash

Click Start, type Git Bash, open it. You can also use Command Prompt. The commands below work in both.

04

Confirm Git is installed

You should see a version number, not an error.

copy this exactly
git --version
05

Set the name that will appear on commits

Use the real name of the person who uses this PC, so you can tell whose changes are whose.

copy this exactly
git config --global user.name "Your Name"
06

Set the email for commits

copy this exactly
git config --global user.email "[email protected]"
07

Open Forgejo from this PC

In a browser, go to http://YOUR-UBUNTU-IP:3000 and sign in. If the page does not load, the Ubuntu machine is off, on a different network, or the IP changed.

08

Clone the repository onto this PC

This creates a folder with a full local copy. You can work in that folder even when Ubuntu is asleep.

copy this exactly
git clone http://YOUR-UBUNTU-IP:3000/yourusername/your-repo.git

Note. Git will ask for the Forgejo username and password. On Windows, Git Credential Manager can remember them.

09

Go into the folder

copy this exactly
cd your-repo
10

Make a tiny test change

This proves the wire works before you put real work in.

copy this exactly
echo Hello from this Windows PC >> from-this-pc.txt
git add .
git commit -m "Test from this PC"
git push origin main

Note. If the default branch is master, use master instead of main. Check with: git branch

11

Refresh the Forgejo page in the browser

You should see the new file and the commit. If you do, this Windows computer is connected. Repeat this whole section on the next PC.

C

Daily workflow when Ubuntu is not always on

On any Windows computer · 2 min whenever you sync

You can write and save all day with Ubuntu off. Commits stay on that PC. Sync only happens while the server is awake.

How the pieces talk

Windows PC
your working copy
PUSH to the server
Ubuntu · Forgejo
the meeting point
PULL from the server
Other Windows PCs
pull to catch up

Ubuntu off: commit locally. Ubuntu on: pull, then push. The three Windows machines never sync to each other directly.

01

Work offline any time

Edit files in your local repo folder. Git add and git commit work with Ubuntu off. Push and pull do not. They need the server.

copy this exactly
git add .
git commit -m "What I changed"
02

When you want to sync, power on Ubuntu

Wait about one minute. Forgejo is set to restart: always, so it comes back by itself.

03

Confirm the workshop is open

On a Windows browser, load http://YOUR-UBUNTU-IP:3000. If it loads, you can sync.

copy this exactly
docker ps

Note. Run docker ps on Ubuntu if you want to double-check. You should see forgejo Up.

04

PULL first — get other people's work

On the Windows PC you are using, open the repo folder and pull. This copies commits FROM the Ubuntu server TO this PC.

copy this exactly
cd your-repo
git pull origin main

Caution. Always pull before you push. If two PCs committed while Ubuntu was off, the second one to push will be rejected until it pulls.

05

PUSH — send this PC's work to Ubuntu

This copies commits FROM this PC TO the Ubuntu server. The other Windows computers will not see it until they pull.

copy this exactly
git push origin main
06

On the other two Windows PCs, pull

Each machine has its own folder. Each one must pull to catch up. There is no magic sync between Windows PCs — Ubuntu is the meeting point.

copy this exactly
cd your-repo
git pull origin main
07

If Git talks about a merge conflict

Two PCs edited the same lines. Open the listed files, look for the conflict markers, keep the right text, then:

copy this exactly
git add .
git commit -m "Merge both computers"
git push origin main
08

You may shut Ubuntu down after everyone has pushed

You do not need to stop Docker first. Just shut down the computer as usual. Next time you power it on, Forgejo starts again.

D

Optional: back up to OneDrive

On Ubuntu, before a long shutdown · 15 min the first time

The live copy lives in ~/forgejo/data. OneDrive is a spare, not the daily sync. Git already copies history to every PC that has cloned.

01

Pause Forgejo before copying, if it is running

A quiet copy is a clean copy.

copy this exactly
cd ~/forgejo && docker compose stop
02

Install rclone

copy this exactly
sudo apt install -y rclone
03

Connect rclone to OneDrive

Follow the prompts. Choose Microsoft OneDrive, sign in in the browser it opens, then give the remote a short name such as onedrive.

copy this exactly
rclone config
04

Copy the data folder to OneDrive

copy this exactly
rclone copy ~/forgejo/data onedrive:forgejo-backup --progress

Note. Replace onedrive with the remote name you chose. Run this whenever you want a fresh spare.

05

Start Forgejo again

copy this exactly
cd ~/forgejo && docker compose start
?

Words on the box

Keep this nearby

Push and pull are two directions. Mixing them up is the usual snag.

Pull
Download commits from Ubuntu onto this computer. Use it to catch up.
Push
Upload this computer's commits to Ubuntu. Other PCs will not see them until they pull.
Commit
A snapshot saved on this computer. Works with Ubuntu off. Nothing leaves the PC until you push.
Clone
The first copy. Creates the folder on a new computer and points it at Ubuntu.
Origin
Git's nickname for the Ubuntu Forgejo server.

No sign-in — progress stays on this device. Say the word and I will add accounts.