A convenient bash script to streamline git repository initialization with GitHub integration.
- 🚀 Initializes git repository with
git init - 📝 Creates or checks for
.gitignorewith sensible defaults - 🔍 Scans for sensitive files (secrets, credentials, large files)
- 🤔 Asks user about each potentially sensitive file
- 📚 Creates README.md if missing
- 💾 Creates initial commit
- 🐙 Creates and pushes to GitHub repository using
ghCLI - 🌐 Optionally enables GitHub Pages with automatic URL link in README
- 🔗 Creates live demo at
username.github.io/repo-name - 🖼️ Auto-embeds
screenshot.png(if present) into README with a centered preview - 🗂️ Prompts for
catalogue.jsonmetadata so the homepage catalogue can index the repo - 🤖 (Optional) Uses OpenAI to prefill
catalogue.jsonfields whenOPENAI_API_KEYis set - ♻️
gir -mmodify mode retrofits existing repos (README, .gitignore, Pages guidance) - 🧹 Optional cleanup: delete local folder after pushing to GitHub
The installation has already been completed! The script is located in ~/gitBash/ and configured in your .zshrc.
- git-init-repo.sh - Main script that handles repository initialization
- init.sh - Configuration file sourced by your shell
- .zshrc - Updated to load the gitBash scripts
To use the script, navigate to any directory where you want to initialize a git repository and run:
git-init-repoOr use the shorter alias:
girgir -mgir -m is perfect after cloning an older project—you'll get the README template, .gitignore, screenshot embedding, GitHub Pages guidance, and optional push without re-running git init.
- Runs
git initin the current directory - Creates a
.gitignorefile if one doesn't exist - Scans for:
- Files with "secret", "password", "credentials" in the name
.pem,.key,.envfiles.yamland.jsonfiles- Large files (>10MB)
- Asks you about each file found whether to ignore it or track it
- Updates
.gitignoreaccordingly - Creates a
README.mdif missing (asks for repo name and description) - Runs
git add . - Runs
git commit -m 'init commit' - Asks if repo should be public or private
- Creates GitHub repository using
ghCLI - Pushes the initial commit to GitHub
- Asks if you want to enable GitHub Pages
- If enabled, sets up GitHub Pages from the main branch
- Adds a live demo link to your README (e.g.,
https://username.github.io/repo-name) - Commits and pushes the updated README
- Detects
screenshot.png(or .jpg/.jpeg variants) and adds a centered preview to README - Prompts you to create/update
catalogue.jsonso the homepage catalogue can auto-ingest the repo (optionally prefilled via OpenAI whenOPENAI_API_KEYis set) - In modify mode, optionally pushes your new commit to origin
- In init mode, optionally deletes the local folder after everything is safely on GitHub
The script automatically detects your project type and provides intelligent suggestions:
- Detected: Projects with
index.htmland no backend dependencies - Action: Offers to enable GitHub Pages
- Perfect for: HTML/CSS/JS, React builds, portfolio sites
The script detects:
- Python backends (Flask, FastAPI, Gradio, Streamlit, Django)
- Node.js backends (Express, Koa, Fastify, NestJS)
- Apps in
requirements.txtorpackage.json
When detected, the script will:
- Warn you that GitHub Pages won't work
- Detect if it's designed for local use (and suggest keeping it local)
- Suggest appropriate hosting alternatives:
- Render.com - Free tier, easy Python/Node hosting
- Railway.app - Free tier, simple deployment
- Hugging Face Spaces - Free, perfect for Gradio/ML apps
- Vercel - Great for Next.js and serverless
- Netlify - Static sites and some serverless functions
The script suggests but doesn't implement these alternatives - you stay in control!
Scenario 1: Simple HTML Game
Detecting project type...
✓ Detected: Static website (HTML/CSS/JS)
This project is perfect for GitHub Pages!
Do you want to enable GitHub Pages? (y/n):
Scenario 2: Gradio AI App
Detecting project type...
⚠️ Detected: Python backend app
GitHub Pages only works for static HTML/CSS/JS sites.
This project requires a server to run.
Note: This appears to be designed for LOCAL use only.
Consider if hosting it publicly is necessary/desired.
If you want to host this online, consider:
• Render.com (free), Railway.app, or Hugging Face Spaces (for Gradio/ML apps)
Do you still want to try enabling GitHub Pages? (not recommended) (y/n):
When you enable GitHub Pages for static sites, the script will:
- Configure GitHub Pages to serve from your main branch
- Create a live demo URL at
https://username.github.io/repo-name - Automatically add a "🚀 Live Demo" link at the top of your README
- Commit and push the updated README
If a screenshot.png, screenshot.jpg, or screenshot.jpeg exists in the project root, the script:
- Detects it automatically
- Adds a
## Previewsection to the README - Embeds the image centered at 720 px width for a polished look
- Skips if the screenshot is already referenced (avoids duplicates)
To power the cards on the homePage project, the script now manages catalogue.json following the guidance in catalogue_metadata.md:
- Prompts you (in both init and modify modes) to create or refresh
catalogue.json - Collects title, ID, one-liner, demo URL, screenshot path, kind, categories, tags, and status
- Auto-suggests sensible defaults (repo name, GitHub URL, detected screenshot path, etc.)
- Outputs valid JSON that the homepage workflow ingests automatically
If you set OPENAI_API_KEY (and optionally OPENAI_MODEL, default gpt-4o-mini), gir will:
- Offer to call OpenAI and read your README/index/automation notes
- Receive a draft
catalogue.json - Prefill every prompt with the AI’s suggestion so you can confirm/tweak
- If the API is unavailable or rate-limited (HTTP 429),
girautomatically falls back to manual entry
Set up in your shell config:
export OPENAI_API_KEY="sk-..."
# Optional: export OPENAI_MODEL="gpt-4o-mini"You can always skip or re-run gir -m later if you need to update the catalogue entry.
Use gir -m inside an existing repository to retrofit all the niceties:
- Keeps the current
.githistory—no re-initialization - Regenerates
.gitignore, README scaffold, screenshot previews, and sensitive-file scans - Provides the same GitHub Pages intelligence/warnings without creating a new repo
- Lets you enter a fresh commit message (defaults to
chore: repo retrofit) - Prompts to push the new commit to origin when finished
Perfect for older projects you wish had the new automation—just clone, run gir -m, and follow the prompts.
Note: GitHub Pages requires a public repository, or a GitHub Pro/Team/Enterprise account for private repos.
After successfully pushing to GitHub (init mode only), the script asks if you want to delete the local folder to keep your computer clean.
Safety features:
- Shows exactly what will be deleted
- Requires typing 'DELETE' to confirm (prevents accidental deletion)
- Navigates to parent directory before deleting
- Displays your new location after cleanup
Use case: Perfect when you're initializing a project just to get it on GitHub and don't need a local copy, or when you want to clone it fresh later.
- Git installed on your system
- GitHub CLI (gh) installed and authenticated
- Install:
brew install gh - Login:
gh auth login
- Install:
- Optional:
OPENAI_API_KEYenvironment variable (andpython3) to enable AI-assisted catalogue prefill
The script is automatically available in new terminal sessions since it's configured in .zshrc.
If you want to use it in your current terminal session without restarting, run:
source ~/.zshrc# Create a new project directory
mkdir my-new-project
cd my-new-project
# Initialize with git and GitHub
git-init-repoThe script will guide you through the process with interactive prompts!
You can edit the scripts:
~/gitBash/git-init-repo.sh- Main script logic~/gitBash/init.sh- Aliases and PATH configuration
After editing, reload your shell configuration:
source ~/.zshrcCommand not found: Make sure you've sourced your .zshrc:
source ~/.zshrcgh authentication error: Make sure GitHub CLI is authenticated:
gh auth status
gh auth login # if not authenticatedPermission denied: Make sure the script is executable:
chmod +x ~/gitBash/git-init-repo.sh