v0.1
This commit is contained in:
99
README.md
Normal file
99
README.md
Normal file
@@ -0,0 +1,99 @@
|
|||||||
|
# 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:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 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:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Requires Go 1.18+
|
||||||
|
go install code.gitea.io/tea@latest
|
||||||
|
```
|
||||||
|
|
||||||
|
**macOS:**
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# Using Homebrew
|
||||||
|
brew tap gitea/tap https://gitea.com/gitea/homebrew-gitea
|
||||||
|
brew install tea
|
||||||
|
```
|
||||||
|
|
||||||
|
Or download manually:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 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
|
||||||
|
|
||||||
|
```bash
|
||||||
|
# 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:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
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:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
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
|
||||||
|
|
||||||
|
- [Gitea API Documentation](https://docs.gitea.com/development/api-usage)
|
||||||
|
- [tea CLI Repository](https://gitea.com/gitea/tea)
|
||||||
Reference in New Issue
Block a user