fristy/GITEA_SETUP.md

4.9 KiB

Gitea Configuration

Server Details

Repository Setup

Initial Push to Gitea

# 1. Remote hinzufügen
git remote add origin http://192.168.1.142:3000/Firstly/fristy.git

# 2. Initial Commit (falls noch nicht gemacht)
git add .
git commit -m "chore: initial project setup"

# 3. Push zu Gitea
git push -u origin main

# 4. Develop Branch erstellen
git checkout -b develop
git push -u origin develop

Authentifizierung

Option 1: HTTPS mit Token

# Token als Passwort verwenden
git remote set-url origin http://<username>:<token>@192.168.1.142:3000/Firstly/fristy.git

Option 2: Git Credential Helper

# Token speichern
git config credential.helper store
# Beim nächsten Push Token eingeben

Option 3: SSH (empfohlen für lokales Netzwerk)

# SSH-Key generieren
ssh-keygen -t ed25519 -C "your-email@example.com"

# Public Key zu Gitea hinzufügen
# Unter: http://192.168.1.142:3000/user/settings/keys

# Remote auf SSH umstellen
git remote set-url origin git@192.168.1.142:Firstly/fristy.git

Gitea-spezifische Features

Branch Protection

  1. Gehe zu Repository Settings
  2. Branches → Protected Branches
  3. Schütze main und develop:
    • Require pull request reviews before merging
    • Require status checks to pass
    • Include administrators

Webhooks (für CI/CD)

  1. Settings → Webhooks
  2. Add Webhook → Gitea
  3. Payload URL: http://your-ci-server/webhook
  4. Events:
    • Push
    • Pull Request
    • Release

Repository Visibility

  • Private: Nur für Team sichtbar
  • Public: Öffentlich zugänglich

CI/CD mit Gitea Actions

Gitea unterstützt GitHub Actions-kompatible Workflows!

.gitea/workflows/ci.yml

name: CI

on:
  push:
    branches: [main, develop]
  pull_request:
    branches: [main, develop]

jobs:
  test:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: '18'
      - run: npm ci
      - run: npm run lint
      - run: npm run type-check
      - run: npm test

Team-Zugriff

Collaborators hinzufügen

  1. Repository → Settings → Collaborators
  2. Add Collaborator
  3. Rechte festlegen:
    • Read: Nur lesen
    • Write: Lesen + Schreiben
    • Admin: Volle Rechte

Nützliche Gitea-Befehle

# Status prüfen
git remote -v

# Änderungen pushen
git push origin feature/mein-feature

# Pull Request via CLI (gh-cli oder tea)
tea pr create --title "Mein Feature" --body "Beschreibung"

# Releases erstellen
git tag -a v0.1.0 -m "Release v0.1.0"
git push origin v0.1.0

Gitea CLI Tool (tea)

# Installation
brew install tea  # macOS
# oder: https://gitea.com/gitea/tea

# Login
tea login add

# Repository clonen
tea clone Firstly/fristy

# Issues erstellen
tea issues create

# Pull Requests
tea pr list
tea pr create

Backup-Strategie

Lokales Backup

# Kompletter Clone mit allen Branches
git clone --mirror http://192.168.1.142:3000/Firstly/fristy.git

Automatisches Backup

# Cron-Job für tägliches Backup
0 2 * * * git -C /path/to/backup/fristy.git fetch --all

Troubleshooting

SSL-Zertifikat-Fehler

# Für lokales Netzwerk (nur Development!)
git config --global http.sslVerify false

Token-Authentifizierung

# Token in URL
git clone http://token@192.168.1.142:3000/Firstly/fristy.git

# Oder in .netrc speichern
# ~/.netrc
machine 192.168.1.142
login username
password ec01d92db7f02dec1089cbb00076d9cbd533fd3f

Push wird abgelehnt

# Force Push vermeiden!
# Stattdessen:
git pull --rebase origin main
git push origin main

Best Practices

DO

  • Token in .env speichern (nicht in Git!)
  • Branch Protection für main/develop
  • Pull Requests für alle Features
  • Issues für Bug-Tracking
  • Releases mit Tags

DON'T

  • Token in Code commiten
  • Direkt auf main pushen
  • Force Push auf shared branches
  • Große Binärdateien committen

Quick Commands

# Repository initialisieren und pushen
git init
git add .
git commit -m "chore: initial project setup"
git remote add origin http://192.168.1.142:3000/Firstly/fristy.git
git push -u origin main

# Develop Branch
git checkout -b develop
git push -u origin develop

# Feature entwickeln
git checkout -b feature/auth-screens
# ... entwickeln ...
git push origin feature/auth-screens
# Dann: Pull Request in Gitea erstellen