3.2 KiB
3.2 KiB
name: gitea
description: Gitea integration and repository management. Use when user needs to: (1) Configure Gitea connection and SSH access, (2) Create and manage Gitea repositories, (3) Set up Git global configuration, (4) Push/pull code from Gitea, (5) Add SSH keys to Gitea account. Handles SSH key generation, Gitea API operations, and Git workflow automation.
Gitea
Overview
Manage Gitea self-hosted Git service integration, including SSH key setup, repository creation, and Git configuration for seamless workflow.
Core Capabilities
1. Initial Configuration
- Set up Git global config (user.name, user.email)
- Generate SSH key pair (ED25519 preferred)
- Configure SSH to use custom port (default: 4022)
- Add SSH public key to Gitea via API
2. Repository Management
- Create new repositories via Gitea API
- Initialize local git repository
- Configure git remote (origin)
- Create initial commit with .gitignore
3. SSH Connection
- Configure SSH host in ~/.ssh/config
- Add host to known_hosts
- Test SSH connection to Gitea
- Push code to remote repository
Configuration File
See references/gitea-config.md for:
- Current Gitea server details
- SSH configuration
- API access information
- Git global settings
Workflow: Full Setup
Step 1: Git Global Configuration
git config --global user.name "username"
git config --global user.email "email@example.com"
Step 2: Generate SSH Key
ssh-keygen -t ed25519 -C "email@example.com" -f ~/.ssh/id_ed25519 -N ""
Step 3: Add SSH Key to Gitea
# Read public key
cat ~/.ssh/id_ed25519.pub
# Add via API
curl -X POST "http://GITEA_URL/api/v1/user/keys" \
-H "Authorization: token ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"title":"KEY_NAME","key":"PUBLIC_KEY"}'
Step 4: Configure SSH
Add to ~/.ssh/config:
Host GITEA_IP
HostName GITEA_IP
Port SSH_PORT
User git
IdentityFile ~/.ssh/id_ed25519
Step 5: Create Repository
curl -X POST "http://GITEA_URL/api/v1/user/repos" \
-H "Authorization: token ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"name":"REPO_NAME","description":"DESC","private":false}'
Step 6: Initialize Git
git init
git add .
git commit -m "Initial commit"
git remote add origin git@GITEA_IP:username/repo.git
git push -u origin main
API Reference
Gitea API Base
- URL:
http://GITEA_IP:PORT/api/v1
Key Endpoints
- Add SSH Key:
POST /api/v1/user/keys - Create Repo:
POST /api/v1/user/repos - List Repos:
GET /api/v1/user/repos - Get Repo:
GET /api/v1/repos/{owner}/{repo}
See references/gitea-config.md for current server details and access tokens.
SSH Connection Test
ssh -T -p SSH_PORT git@GITEA_IP
# Expected: "Hi there, username! You've successfully authenticated..."
Troubleshooting
SSH "Host key verification failed"
Add host to known_hosts:
ssh-keyscan -p SSH_PORT GITEA_IP >> ~/.ssh/known_hosts
Git "Permission denied"
- Verify SSH key is added to Gitea
- Check ~/.ssh/config has correct port and user
- Test SSH connection with
ssh -T git@GITEA_IP