Scripts2026年4月10日·1 分钟阅读

Gitea — Lightweight Self-Hosted Git Service

Gitea is a painless self-hosted Git service with code hosting, review, CI/CD, package registry, and project management — a lightweight GitHub/GitLab alternative.

SC
Script Depot · Community
快速使用

先拿来用,再决定要不要深挖

这里应该同时让用户和 Agent 知道第一步该复制什么、安装什么、落到哪里。

docker run -d --name gitea -p 3000:3000 -p 2222:22 -v gitea-data:/data gitea/gitea:latest

Open http://localhost:3000 — complete the installation wizard and create your first repository.

介绍

Gitea is a lightweight, self-hosted Git service that provides a complete software development platform. Written in Go, it's designed to be simple to install and run, offering GitHub-like features including code hosting, pull requests, code review, CI/CD (Gitea Actions), package registry, and project management — all in a single binary.

With 54.8K+ GitHub stars and MIT license, Gitea is one of the most popular self-hosted Git solutions, valued for its low resource usage, ease of deployment, and comprehensive feature set.

What Gitea Does

Gitea provides a full software development lifecycle:

  • Git Hosting: Repository management with branch protection, webhooks, and deploy keys
  • Code Review: Pull requests with inline comments, reviews, approvals, and merge strategies
  • Issue Tracking: Issues with labels, milestones, projects, and kanban boards
  • CI/CD: Gitea Actions (GitHub Actions compatible) for automated workflows
  • Package Registry: Host Docker images, npm, Maven, PyPI, NuGet, and more
  • Wiki: Built-in wiki for project documentation
  • Organizations & Teams: Multi-user with organization structure and team permissions

Architecture

┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│  Web UI      │────▶│  Gitea       │────▶│  SQLite /    │
│  (Go + Vue)  │     │  Server (Go) │     │  PostgreSQL /│
└──────────────┘     └──────┬───────┘     │  MySQL       │
                            │             └──────────────┘
                     ┌──────┴───────┐
                     │  Git Repos   │
                     │  (Filesystem)│
                     └──────────────┘

Gitea runs as a single binary with embedded web server and Git operations. It supports SQLite (zero-config), PostgreSQL, MySQL, and MSSQL as database backends.

Installation Options

Docker (Recommended)

services:
  gitea:
    image: gitea/gitea:latest
    ports:
      - "3000:3000"    # Web UI
      - "2222:22"      # SSH
    environment:
      GITEA__database__DB_TYPE: postgres
      GITEA__database__HOST: db:5432
      GITEA__database__NAME: gitea
      GITEA__database__USER: gitea
      GITEA__database__PASSWD: gitea
    volumes:
      - gitea-data:/data
    depends_on:
      - db

  db:
    image: postgres:16-alpine
    environment:
      POSTGRES_USER: gitea
      POSTGRES_PASSWORD: gitea
      POSTGRES_DB: gitea
    volumes:
      - pg-data:/var/lib/postgresql/data

volumes:
  gitea-data:
  pg-data:

Single Binary

# Download and run directly
wget https://dl.gitea.com/gitea/latest/gitea-latest-linux-amd64
chmod +x gitea-latest-linux-amd64
./gitea-latest-linux-amd64 web

Kubernetes with Helm

helm repo add gitea https://dl.gitea.com/charts/
helm install gitea gitea/gitea --namespace gitea --create-namespace

Key Features

Gitea Actions (CI/CD)

Gitea Actions is compatible with GitHub Actions syntax:

# .gitea/workflows/ci.yaml
name: CI
on: [push, pull_request]
jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 20
      - run: npm ci
      - run: npm test
      - run: npm run build

Package Registry

Host your own packages alongside code:

# Docker registry
docker tag myapp:latest gitea.example.com/org/myapp:latest
docker push gitea.example.com/org/myapp:latest

# npm registry
npm publish --registry=https://gitea.example.com/api/packages/org/npm/

Supported package types: Docker, npm, PyPI, Maven, NuGet, Cargo, Composer, Conan, Conda, Go, Helm, and more.

Migration Tools

Easily migrate from other platforms:

Supported sources:
├── GitHub (repos, issues, PRs, wiki, labels, milestones)
├── GitLab (repos, issues, PRs, labels)
├── Bitbucket
├── Gogs
└── Gitea (other instances)

Resource Comparison

Metric Gitea GitLab CE Gogs
RAM (idle) ~150MB ~2GB ~100MB
Binary size ~100MB 2GB+ (install) ~60MB
CI/CD Built-in (Actions) Built-in External
Package registry Yes Yes No
Container registry Yes Yes No

Gitea vs Alternatives

Feature Gitea GitHub GitLab CE Gogs
Open Source Yes (MIT) No Yes (MIT) Yes (MIT)
Self-hosted Yes Enterprise Yes Yes
CI/CD Gitea Actions GitHub Actions GitLab CI External
Package registry Yes Yes Yes No
Resource usage Low N/A High Very low
Actions compat. GitHub Actions Native Own syntax No

常见问题

Q: Gitea 和 GitLab 选哪个? A: 如果你需要轻量级、低资源消耗的 Git 服务,选 Gitea(150MB RAM vs GitLab 的 2GB+)。如果需要企业级 DevOps 平台(内置 CI/CD、安全扫描、容器注册),选 GitLab。

Q: Gitea Actions 和 GitHub Actions 兼容性如何? A: 大部分 GitHub Actions workflow 可以直接在 Gitea 上运行。支持 actions/checkout、actions/setup-node 等常用 actions。少数依赖 GitHub 特有 API 的 action 可能需要调整。

Q: 可以从 GitHub/GitLab 迁移吗? A: 可以。Gitea 内置迁移工具,支持从 GitHub、GitLab、Bitbucket 等平台一键迁移仓库、Issues、PR 和 Wiki。

来源与致谢

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产