Files
GiteaRemote/README.md
2026-01-22 21:04:29 +01:00

2.4 KiB

Gitea Remote Management

Remote management of Gitea repositories via CLI tools and API.

Overview

This guide covers how to remotely create bare repositories in a local Gitea instance using CLI tools - useful for bulk importing existing projects.

Options

1. Official Gitea CLI: tea

Gitea has an official CLI tool called tea that can manage repositories remotely.

Installation

Debian/Ubuntu:

# Download the latest release (check https://gitea.com/gitea/tea/releases for current version)
wget https://gitea.com/gitea/tea/releases/download/v0.9.2/tea-0.9.2-linux-amd64
chmod +x tea-0.9.2-linux-amd64
sudo mv tea-0.9.2-linux-amd64 /usr/local/bin/tea

Alternatively, build from source:

# Requires Go 1.18+
go install code.gitea.io/tea@latest

macOS:

# Using Homebrew
brew tap gitea/tap https://gitea.com/gitea/homebrew-gitea
brew install tea

Or download manually:

# For Apple Silicon (M1/M2/M3)
curl -L https://gitea.com/gitea/tea/releases/download/v0.9.2/tea-0.9.2-darwin-arm64 -o tea
# For Intel Macs
curl -L https://gitea.com/gitea/tea/releases/download/v0.9.2/tea-0.9.2-darwin-amd64 -o tea

chmod +x tea
sudo mv tea /usr/local/bin/

Usage

# Login to your instance
tea login add --name mygitea --url https://gitea.example.com --token YOUR_API_TOKEN

# Create a new repository
tea repo create --name my-new-repo --private

2. Gitea REST API

You can use the API directly with curl or any HTTP client:

curl -X POST "https://gitea.example.com/api/v1/user/repos" \
  -H "Authorization: token YOUR_API_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"name": "my-new-repo", "private": true}'

3. Bulk Import Strategy

For adding many existing projects, you can script the process:

for dir in /path/to/projects/*/; do
  repo_name=$(basename "$dir")
  # Create remote repo via API
  curl -X POST "https://gitea.example.com/api/v1/user/repos" \
    -H "Authorization: token $GITEA_TOKEN" \
    -d "{\"name\": \"$repo_name\"}"
  # Add remote and push
  cd "$dir"
  git remote add gitea "https://gitea.example.com/user/$repo_name.git"
  git push --mirror gitea
done

Getting an API Token

In Gitea: Settings → Applications → Generate New Token

Resources