#2 Git
Cours de Julie Chaumard
Why using Git ?
Using Git is an essential best practice, whether youâre working solo or in a team.
- Full history of changes
- Git keeps track of every version of your code.
- You can see who changed what, when, and why.
- You can roll back to a previous state of the project if something breaks.
- Protection against mistakes
- You can experiment in branches without affecting the main project.
- If something breaks, you can easily undo or reset the changes.
- Git doesnât delete anything unless you explicitly tell it to.
- Structured teamwork
- Git allows multiple developers to work on the same project simultaneously.
- Each developer works in their own branch, then merges changes safely.
- Git helps you resolve conflicts and collaborate efficiently.
- Remote backup of your code
- By using a Git server (like Gitea, GitHub, GitLabâŠ), you can back up your code online.
- If your laptop crashes, your project is still safe and accessible.
- Modern workflows: CI/CD, DevOps, automationâŠ
- Git is the foundation of modern development workflows.
- You can automate tasks after every push: testing, deploying, checking security, etc.
- It fits perfectly into DevOps and continuous integration pipelines.
- Documentation through commits
- Your commits become a logbook for the project.
- With git log, you can read past commit messages and understand how the project evolved.
A good developer also documents their decisions with meaningful commits.
Gitea
Why Gitea ?
Why use Gitea? (Key Advantages)
- Self-hosted on your own server
Gitea runs on your own infrastructure (VPS, local server, school network).
Ideal if you want full control over your source code and infrastructure.
No reliance on third-party cloud providers.
- Privacy and data sovereignty
No data is sent to Microsoft (GitHub) or GitLab Inc.
Everything is stored on your own server, under your control.
You manage backups, access, retention policies, etc.
- Lightweight, fast, and easy to install
Gitea is a single binary, very easy to deploy.
Low memory footprint, fast performance.
Much simpler than installing full GitLab CE.
- Free, open source, and community-driven
Gitea is fully open source (MIT license) and maintained by an independent community.
No third-party accounts or subscriptions needed.
No limits on private repositories (unlike GitHub Free).
- Great for learning and teaching
Why not use Gitea?
- If you need a full DevOps pipeline with integrated CI/CD tools â GitLab is more complete.
- If you donât want to manage a server at all â GitHub and GitLab Cloud handle everything for you.
Gitea vs GitLab
Feature / Tool | GitLab CE | Gitea |
---|---|---|
Server footprint | Very heavy (~4â6 GB RAM minimum) | Very lightweight (~100 MB RAM) |
Built-in CI/CD | Yes (very powerful) | Not built-in (possible via Drone) |
Installation complexity | High | Very simple |
System administration | Complex (PostgreSQL, Redis, etc.) | Minimal (single binary + MySQL/SQLite) |
User interface | Very rich, sometimes overloaded | Simple and fast |
Installation of Gitea
User schiller : gitea_school / Sch1ler_git@ (projet@parisweb.art)
(To start the Gitea service :
sudo systemctl stop gitea
sudo -u git GITEA_WORK_DIR=/var/lib/gitea /usr/local/bin/gitea web --port 3001
- Which operating system are you using? Debian
- Which DBMS do you want to use? MySQL
- Will your Gitea instance be installed on the same machine as the database? Same machine
- How are you installing Gitea (binary, Docker, system package, or other)? Binary
Prerequisite : git
Git Install on Debian
sudo apt update
sudo apt upgrade
sudo apt install git
git --version
git version 2.39.5
Create the Gitea Database and a dedicated OS user
sudo mysql -u root -p
CREATE DATABASE gitea CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
CREATE USER 'gitea_user'@'localhost' IDENTIFIED BY '********';
GRANT ALL PRIVILEGES ON gitea.* TO 'gitea_user'@'localhost';
FLUSH PRIVILEGES;
When you launch the Gitea web installation script (http://localhost:3000), you will need to provide the following information:
- Database Type: MySQL
- Host: 127.0.0.1:3306
- User: gitea_user
- Password: ********
- Database Name: gitea
The Gitea installer will then write this into the file: custom/conf/app.ini.
Create a dedicated system user for Gitea
sudo adduser \
--system \
--shell /bin/bash \
--gecos 'Git Version Control' \
--group \
--disabled-password \
--home /home/git \
git
// Add the user debian to the git group
sudo usermod -aG git debian
Install
cd /home/git
sudo wget -O gitea https://dl.gitea.com/gitea/1.24.5/gitea-1.24.5-linux-amd64
sudo chmod +x gitea
ls -l
// Make the binary accessible system-wide
sudo mv gitea /usr/local/bin/gitea
// Create necessary folders
sudo mkdir -p /var/lib/gitea/{custom,data,log}
sudo chown -R git:git /var/lib/gitea/
sudo chmod -R 750 /var/lib/gitea/
sudo mkdir /etc/gitea
sudo chown root:git /etc/gitea
sudo chmod 770 /etc/gitea
// Create the systemd service (to run Gitea as a service)
sudo nano /etc/systemd/system/gitea.service
// dd this content
[Unit]
Description=Gitea (Git with a cup of tea)
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
// Start Gitea
sudo systemctl daemon-reexec
sudo systemctl enable --now gitea
// Check Gitea service
sudo systemctl status gitea
â gitea.service - Gitea (Git with a cup of tea)
Loaded: loaded (/etc/systemd/system/gitea.service; enabled; preset: enabled)
Active: active (running) since Sun 2025-08-17 19:15:59 UTC; 28s ago
Main PID: 55453 (gitea)
Tasks: 8 (limit: 2290)
Memory: 97.6M
CPU: 335ms
CGroup: /system.slice/gitea.service
ââ55453 /usr/local/bin/gitea web --config /etc/gitea/app.ini
Aug 17 19:15:59 vps-38339055 gitea[55453]: 2025/08/17 19:15:59 cmd/web.go:114:showWebStartupMessage() [I] Gitea version: 1.24.5 built with GNU Make 4.3, go1.24.6 : bindata, sql>
Aug 17 19:15:59 vps-38339055 gitea[55453]: 2025/08/17 19:15:59 cmd/web.go:115:showWebStartupMessage() [I] * RunMode: prod
Aug 17 19:15:59 vps-38339055 gitea[55453]: 2025/08/17 19:15:59 cmd/web.go:116:showWebStartupMessage() [I] * AppPath: /usr/local/bin/gitea
Aug 17 19:15:59 vps-38339055 gitea[55453]: 2025/08/17 19:15:59 cmd/web.go:117:showWebStartupMessage() [I] * WorkPath: /var/lib/gitea/
Aug 17 19:15:59 vps-38339055 gitea[55453]: 2025/08/17 19:15:59 cmd/web.go:118:showWebStartupMessage() [I] * CustomPath: /var/lib/gitea/custom
Aug 17 19:15:59 vps-38339055 gitea[55453]: 2025/08/17 19:15:59 cmd/web.go:119:showWebStartupMessage() [I] * ConfigFile: /etc/gitea/app.ini
Aug 17 19:15:59 vps-38339055 gitea[55453]: 2025/08/17 19:15:59 cmd/web.go:120:showWebStartupMessage() [I] Prepare to run install page
Aug 17 19:15:59 vps-38339055 gitea[55453]: 2025/08/17 19:15:59 cmd/web.go:323:listen() [I] Listen: http://0.0.0.0:3000
Aug 17 19:15:59 vps-38339055 gitea[55453]: 2025/08/17 19:15:59 cmd/web.go:327:listen() [I] AppURL(ROOT_URL): http://localhost:3000/
Aug 17 19:15:59 vps-38339055 gitea[55453]: 2025/08/17 19:15:59 modules/graceful/server.go:50:NewServer() [I] Starting new Web server: tcp:0.0.0.0:3000 on PID: 55453
// Change the port from 3000 to 3001
// Start Gitea manually from the command line with a specific port (e.g., 3001), without modifying app.ini
sudo systemctl stop gitea
sudo -u git GITEA_WORK_DIR=/var/lib/gitea /usr/local/bin/gitea web --port 3001
Start Gitea service
// Start Gitea manually from the command line with a specific port (e.g., 3001), without modifying app.ini
sudo systemctl stop gitea
sudo -u git GITEA_WORK_DIR=/var/lib/gitea /usr/local/bin/gitea web --port 3001
Browser Install with VPS IP
Root location for repositories: /var/lib/gitea/data/gitea-repositories
Git LFS root directory: /var/lib/gitea/data/lfs
Log file path: /var/lib/gitea/log
Gitea base URL: http://51.210.180.18:3001/
Administrator username: gitea_admin
Email: contact@parisweb.art
Pasword : ******
These configuration options will be written into: :Â /var/lib/gitea/custom/conf/app.iniÂ
sudo nano /etc/systemd/system/gitea.service
Chnage this line ExecStart=/usr/local/bin/gitea web --config /etc/gitea/app.ini
par ExecStart=/usr/local/bin/gitea web --config /var/lib/gitea/custom/conf/app.ini
sudo systemctl daemon-reexec
sudo systemctl restart gitea
sudo netstat -tulnp | grep gitea
Gitea Dashboard url
After the install you open Git via http://51.210.180.18:3001/
Configure a reverse proxy NGINX + HTTPS
/etc/nginx/sites-available/gitea
server {
listen 80;
server_name git.parisweb.art;
location / {
proxy_pass http://127.0.0.1:3001;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
File configuration /var/lib/gitea/custom/conf/app.ini, after the https configuration
sudo nano /var/lib/gitea/custom/conf/app.ini
Change ROOT_URL = http://51.210.180.18:3001/ with ROOT_URL = http://git.parisweb.art/
[server]
ROOT_URL = http://git.parisweb.art/
sudo systemctl restart gitea
https
cd /etc/nginx/sites-available
sudo certbot --nginx -d git.parisweb.art
sudo nano /var/lib/gitea/custom/conf/app.ini
Modifier ROOT_URL = https://git.parisweb.art/
sudo systemctl restart gitea
Configure SMTP to be able to send mails
Put code on Gitea
Log in to your instance and create a repository
- Go to https://git.parisweb.art
- Log in with your account
- Click on â+â > âNew Repositoryâ
- Fill in the information:
- Repository name: mon-projet
- Description: optional
- Visibility: public or private
- Uncheck âInitialize with READMEâ if you want to push an existing repository
- Click on âCreate Repositoryâ
For example, the repository created: quiz_konexio https://git.parisweb.art/gitea_school/quiz_konexio
Sync a project between Gitea and a development computer
- Clone the project from Gitea
- Open the terminal and clone the Gitea repository. It will be placed in the current terminal directory.
git clone https://git.parisweb.art/gitea_school/quiz_konexio
- Sync local changes to Gitea
// In the terminal, navigate to the repository folder
git add .
git commit -m "Mon message de commit"
git push origin main
To fetch changes made by other people on Gitea
git pull origin main
Use Git in vscode
Agence digitale Parisweb.art
Tout savoir sur Julie, notre directrice de projets digitaux : https://www.linkedin.com/in/juliechaumard/