Forgejo repo creator
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2026-09-16 07:02:45 +00:00
.gitignore script 2026-09-15 21:33:20 -06:00
forgejo-create.sh script 2026-09-15 21:33:20 -06:00
install.sh script 2026-09-15 21:33:20 -06:00
README.md Update README.md 2026-09-16 07:02:45 +00:00

Forgejo Repository Creator (forgejo-create)

A lightweight, zero-dependency (POSIX bash + curl + git) CLI tool that turns any local folder into a new Forgejo Git repository and pushes all code in a single command.


One-Command Installation

You can install forgejo-create directly into ~/.local/bin (or /usr/local/bin if root):

From your Forgejo repository:

curl -fsSL https://aifg.be2x.com/badmark/forgejo-creator/raw/branch/main/forgejo-create.sh -o ~/.local/bin/forgejo-create && chmod +x ~/.local/bin/forgejo-create

(Or if you host install.sh: curl -fsSL https://aifg.be2x.com/badmark/forgejo-creator/raw/branch/main/install.sh | bash)

From cloned repo:

./install.sh

Note

: Ensure ~/.local/bin is in your $PATH. If not, add export PATH="$HOME/.local/bin:$PATH" to your ~/.bashrc or ~/.zshrc.


🚀 How It Works

1. First Run (Credential Setup)

When you run forgejo-create for the first time, an interactive setup wizard will prompt you for:

  • Forgejo Instance URL: (e.g., https://forgejo.example.com or https://codeberg.org)
  • Forgejo Personal Access Token: Create one in Forgejo under Settings -> Applications -> Generate New Token with repository (Read & Write) permissions.
  • Push Protocol: https (token-authenticated) or ssh (if SSH keys are already configured).
  • Default Visibility: private (default) or public.
  • Default Branch: main (default).

Your configuration is tested and saved securely to ~/.config/forgejo-create/config with strict 0600 permissions.

2. Subsequent Runs (Creating Repositories)

Navigate to any directory on your machine containing code and run:

forgejo-create

The script will:

  1. Prompt for repository name (defaults to current folder name).
  2. Prompt for optional description and visibility.
  3. Authenticate with Forgejo and create the remote repository via API.
  4. Initialize the local Git repository (if not already initialized).
  5. Stage all files (git add -A) and commit them.
  6. Configure the remote origin and push all code directly to Forgejo.
  7. Print the web URL to your new repository!

🛠️ CLI Options

Usage:
  forgejo-create [OPTIONS]

Options:
  -n, --name <name>          Name of the remote repository (default: current directory name)
  -d, --description <text>   Description for the repository
  --public                   Create as a public repository
  --private                  Create as a private repository
  --org <org_name>           Create repository under an organization instead of user account
  -b, --branch <branch>      Initial branch name (default: main)
  --reconfigure              Run the configuration setup wizard again
  -v, --version              Show version information
  -h, --help                 Show this help message

Examples

# Interactive mode (prompts for name and description)
forgejo-create

# Non-interactive quick creation with custom name
forgejo-create -n my-cool-project --public -d "My new project"

# Create under an organization
forgejo-create --org my-org -n microservice-api

# Update stored credentials/URL
forgejo-create --reconfigure

🔒 Security & Credential Storage

Credentials are stored in:

~/.config/forgejo-create/config

This file is generated with chmod 600 (read/write access restricted solely to the owner).