# Git Repository Setup Script for Gitea This script helps you create a git repository from existing codebase and configure it to synchronize with a Gitea server. ## Features - **Multiple Authentication Methods**: - SSH (passwordless with key generation) - HTTPS (with Git Credential Manager) - Tea CLI (full Gitea API integration) - **Advanced Installation Management**: - **Tea CLI**: User-specific installations with version symlinks - **Git Credential Manager**: Automatic detection and setup - **Borg CLI**: Backup tool with smart version management - **Smart Updates**: Only downloads when newer versions available - **Automatic Setup**: - Git repository initialization - SSH key generation and display - Tea CLI installation and configuration - Remote repository creation - Connection testing ## Usage ```bash # Interactive setup ./setup-git-repo.sh # With configuration file echo '{"gitea": {"server_url": "https://your-gitea.com"}}' > config.json ./setup-git-repo.sh ``` ## Available Installers ### Tea CLI Installer ```bash # Install latest Tea CLI ./install-tea-cli.sh # Install specific version ./install-tea-cli.sh -v v0.11.1 # Force reinstall ./install-tea-cli.sh --force ``` ### Borg CLI Installer ```bash # Install latest Borg CLI ./install-borg-cli.sh # Install specific version ./install-borg-cli.sh -v 1.4.2 # Force reinstall ./install-borg-cli.sh --force ``` ### Git Credential Manager Installer ```bash # Install latest GCM ./install-git-credential-manager.sh # Install specific version ./install-git-credential-manager.sh -v v2.6.1 # Force reinstall ./install-git-credential-manager.sh --force # Check configuration without installing ./install-git-credential-manager.sh --checks ``` ## Installation Strategies All installers implement smart installation strategies: ### User-Specific Installations (Preferred) - **Location**: `~/bin/` directory - **Requirements**: `~/bin` exists and is in PATH - **Benefits**: No sudo required, user isolation, multiple versions - **Structure**: ``` ~/bin/ ├── tea -> tea-v0.11.1 # Active version ├── tea-v0.11.0 # Previous version └── tea-v0.11.1 # Current version ``` ### System-Wide Installations (Fallback) - **Location**: `/usr/local/bin/` - **Requirements**: sudo access - **Benefits**: Available to all users - **Structure**: ``` /usr/local/bin/ ├── tea -> tea-v0.11.1 ├── tea-v0.11.0 └── tea-v0.11.1 ``` ### Version Management - **Symlinks**: Automatic version switching - **Multiple Versions**: Keep old versions for rollback - **Smart Updates**: Only download when newer version available ## Configuration The script supports JSON configuration for automation: ```json { "gitea": { "server_url": "https://your-gitea.com", "default_login_name": "$USER", "login_method": "token", "has_access_token": true, "default_auth_method": "3" }, "git": { "default_branch": "main", "auto_init": false }, "ssh": { "key_type": "ed25519", "key_path": "~/.ssh/id_ed25519" }, "repository": { "default_private": false, "auto_add_files": false, "auto_commit": false, "auto_push": false } } ``` 2. Run the script: ```bash ./setup-git-repo.sh ``` 3. Follow the prompts to provide: - Your name and email - Gitea server URL - Repository name and description - Authentication method preference ## Authentication Methods ### 1. SSH (Recommended) - Generates ED25519 SSH key if none exists - Provides passwordless authentication after initial setup - Most secure for automated workflows ### 2. HTTPS - Uses access tokens or password authentication - Good for environments where SSH is blocked - May require credential management ### 3. Tea CLI - Installs and configures Gitea's official CLI tool - Creates repository via Gitea API - Provides additional repository management features ## Requirements - Git installed - Internet connection for Gitea access - Appropriate permissions on Gitea server ## Tea CLI Information The script can automatically install tea CLI, which is Gitea's official command-line tool. Tea provides: - Repository management - Issue and pull request handling - Release management - And much more For more information about tea CLI: https://gitea.com/gitea/tea ## Example Workflow ```bash ./setup-git-repo.sh # Follow prompts... git add . git commit -m "Initial commit" git push -u origin main ``` The script handles all the complex setup, allowing you to focus on your code.