GitGenie is an intelligent command-line interface (CLI) tool designed to simplify and automate Git workflows. It handles common Git operations like committing, branch management, staging, and pushing, while optionally integrating AI-generated commit messages using Google Gemini. This comprehensive documentation details all features, configurations, and functionality implemented to date.
- Website scroll stack animation β sections on the landing page now stack smoothly as you scroll. Hero, Features, How It Works, Use Cases, FAQ, and footer/call-to-action layers use sticky positioning and z-index transitions for a more immersive experience.
- Interactive Command Palette: running
ggwith no arguments opens a menu to pick actions; it shows the exact command it will run. - Shortcuts:
gg b,gg s,gg wt,gg clfor fast branch/worktree/clone flows. - Auto-Detect Commit Type: in non-genie mode, if you donβt pass
--type, the CLI infers a sensible commit type from the diff. - Non-interactive flags:
--no-branchskips the branch prompt and commits directly tomain.--push-to-mainpushes automatically. If youβre on a feature branch, it merges intomainand pushes; if youβre onmain, it just pushes.
npm install -g @gunjanghate/git-genieBefore using AI features, configure your Gemini API key:
gg config YOUR_GEMINI_API_KEY# Manual commit message (default)
gg "add new feature"
# AI-generated commit message
gg "fix authentication bug" --genie
# Commit directly to main (skip branch prompt)
gg "update documentation" --no-branch
# Merge to main and push after commit
gg "add dashboard" --type feat --push-to-mainGitGenie supports multiple ways to configure your Gemini API key:
gg config YOUR_GEMINI_API_KEYThis saves the API key to ~/.gitgenie/config.json for persistent use across all projects.
export GEMINI_API_KEY="your_api_key_here"Create a .env file in your project root:
GEMINI_API_KEY=your_api_key_herePriority Order: Environment variable > Config file > .env file
- Visit Google AI Studio
- Create a new API key
- Configure it using one of the methods above
- Validates Git repository existence and initializes if needed
- Automatic file staging with progress feedback
- AI-powered commit message generation using Google Gemini
- Open source contribution workflow with --osc flag (issue-based branch naming)
- Interactive branch management with auto-suggestions
- Automated merge-to-main workflows
- Retry logic for network operations
- Professional error handling and user feedback
- Cross-platform configuration management
GitGenie now includes convenient shortcut commands for branch management and worktree operations:
gg b <branchName>: Create and switch to a new branchgg s <branchName>: Switch to an existing branchgg wt <branchName> [path]: Create a worktree for a branch at an optional pathgg cl <repoUrl> [directory]: Clone a repository into an optional directory
# Create and switch to a new branch
gg b feature/new-ui
# Switch to an existing branch
gg s main
# Create a worktree for a branch (default path is a folder named after the branch)
gg wt pr2
# Create a worktree for a branch at a custom path
gg wt pr2 ../pr2-folder
# Clone a repository
gg cl https://github.com/username/repo.git
# Clone a repository to a specific directory
gg cl https://github.com/username/repo.git my-custom-folder- Run
ggwith no arguments to open an interactive menu. - Pick actions like βcommitβ, βbβ, βsβ, βwtβ, or βclβ.
- The palette prints the exact command it will run and then executes it.
Example
gg
β Running: gg "add login retries" --type fix --scope auth
These shortcuts make branch and worktree management faster and easier, especially for advanced workflows and multi-branch development.
GitGenie now includes an intelligent commit splitting feature that analyzes your staged changes and groups them into logical, atomic commits.
Problem it solves: Developers often work on multiple things simultaneouslyβfixing a bug, refactoring a function, and updating documentationβbefore running git commit. Committing all these changes together (the "Mega-Commit") leads to messy history, hard code reviews, and risky reverts.
Solution: gg split uses AI to detect semantic relationships between files and suggests breaking them down by feature, refactor, or file dependency.
# Basic usage (AI-powered if API key configured)
gg split
# Force heuristic grouping (no AI)
gg split --no-genie
# Preview groups without committing
gg split --dry-run
# Auto-commit all groups without confirmation
gg split --auto
# Limit maximum number of groups
gg split --max-groups 3# You have multiple changes staged
git add src/auth.js src/auth.test.js src/components/Navbar.css README.md
# Run split
gg split
# Output:
# π Detected Groups:
#
# [Group 1] feat(auth): add login session handling
# Files (2):
# β’ src/auth.js
# β’ src/auth.test.js
#
# [Group 2] fix(ui): resolve navbar z-index issue
# Files (1):
# β’ src/components/Navbar.css
#
# [Group 3] docs: update installation guide
# Files (1):
# β’ README.md
#
# ? How would you like to proceed?
# β Commit all groups as suggested
# βοΈ Review and edit each group
# π Merge groups together
# β Cancel--genie: Use AI-powered grouping (default if API key exists)--no-genie: Use heuristic grouping only (groups by file type and directory)--auto: Auto-commit all groups without confirmation (non-interactive mode)--dry-run: Preview groups without committing--max-groups <n>: Limit maximum number of groups (default: 5)
- AI-Powered Grouping: Uses Google Gemini to analyze semantic relationships
- Heuristic Fallback: Works without API key using smart file categorization
- Interactive Review: Edit commit messages, merge groups, or skip groups
- Error Handling: Graceful handling of all edge cases and failures
- Atomic Commits: Creates clean, logical commit history
The split command handles all error scenarios gracefully:
- No staged changes β prompts to stage
- Single file β suggests using regular commit
- API failures β falls back to heuristic grouping
- Network timeouts β automatic fallback
- Git operation failures β option to continue or abort
- User cancellation (Ctrl+C) β clean exit
gg <description> [options]gg config <api-key> # Save Gemini API key for persistent use<desc>: Short description of the change (mandatory)--type <type>: Commit type (if omitted and not using--genie, GitGenie will auto-detect a likely type from your changes)--scope <scope>: Optional scope for commit message--genie: Enable AI commit message generation using Google Gemini- Auto-detect commit type (non-genie): If you donβt pass
--typeand youβre not using--genie, GitGenie will infer a likely type from your changes. --osc: Open source contribution branch format (prompts for issue number, branch name: type/#issue-shorttitle)--no-branch: Skip interactive branch choice and commit to main--push-to-main: Automatically merge current branch to main and push--remote <url>: Add remote origin if repo is new
feat: New featuresfix: Bug fixesdocs: Documentation changesstyle: Code style changesrefactor: Code refactoringtest: Adding or updating testschore: Maintenance tasksci: CI/CD changesbuild: Build system changesperf: Performance improvements
To help visualize how GitGenie handles your Git operations, the following diagrams outline the internal logic.
graph TD
Start([gg command]) --> Repo{Repo exists?}
Repo -- No --> Init[git init]
Repo -- Yes --> Remote[Remote Origin Setup]
Init --> Remote
Remote --> History{Existing Commits?}
History -- No --> MainOnly[Force Main Branch]
History -- Yes --> BranchCheck{--no-branch or Detached HEAD?}
MainOnly --> Staging
BranchCheck -- Yes --> Staging
BranchCheck -- No --> Menu[Interactive Branch Menu]
Menu --> BranchType{Choice}
BranchType -- Current --> Staging
BranchType -- New --> OSCCheck{--osc flag?}
OSCCheck -- Yes --> OSC[OSC/Issue-branch Flow]
OSCCheck -- No --> Std[Std Branch Flow]
OSC --> Staging
Std --> Staging
subgraph Staging_Process [Multi-Step Staging]
Staging[Check Cached Diff] --> DiffCheck{Changes Found?}
DiffCheck -- No --> StageAll[Prompt & git add .]
DiffCheck -- Yes --> Verify[Verify Staging]
StageAll --> Verify
end
Verify --> GenieMode{--genie flag?}
GenieMode -- Yes --> AI[Gemini Mode: Skip Auto-detect]
GenieMode -- No --> TypeCheck{--type provided?}
TypeCheck -- Yes --> Manual[Apply Manual Type]
TypeCheck -- No --> Auto[Auto-detect Commit Type]
AI --> Commit[git commit]
Manual --> Commit
Auto --> Commit
Commit --> PostCommit{--push-to-main?}
PostCommit -- Yes --> PushLogic
PostCommit -- No --> PushPrompt[Interactive Push Prompt]
graph TD
S[gg split] --> Diff[Analyze Staged Changes]
Diff --> Mode{--no-genie?}
Mode -- No --> AI[Gemini API: Group by Logic]
Mode -- Yes --> Heuristic[Heuristic: Group by File Type]
AI --> Review[Interactive Review Menu]
Heuristic --> Review
Review --> Choice{User Choice}
Choice -- Edit --> Edit[Modify Groups/Messages]
Choice -- Merge --> Merge[Combine Groups]
Choice -- Commit --> Exec[Loop: Atomic Commits]
Edit --> Review
Merge --> Review
Exec --> Done([Clean Working Tree])
graph TD
PushStart[Start Push Workflow] --> RemoteCheck[ensureRemoteOriginInteractive]
RemoteCheck --> BranchLoc{Current Branch?}
BranchLoc -- is main --> Direct[git push origin main]
BranchLoc -- is feature --> Merge[Merge into main]
Merge --> P[git push origin main]
P --> Cleanup[Delete Local & Remote Feature Branch]
Direct --> Final([Success Message])
Cleanup --> Final
subgraph Error_State [Process Exit]
Direct -- Fail --> Err[Throw Error & Exit]
P -- Fail --> Err
end
Note for Contributors: If you modify the orchestration logic in
index.jsorsplit.js, please ensure these diagrams are updated to reflect those changes.
GitGenie Project/
βββ ~/.gitgenie/
β βββ config.json # User configuration file
βββ .env # Optional project environment variables
βββ .git/ # Git repository data
βββ .gitignore # Git ignore rules
βββ index.js # Main application logic
βββ node_modules/ # Dependencies
βββ package.json # Project configuration & dependencies
βββ package-lock.json # Locked dependency versions
βββ README.md # This documentation
- Automatic repository detection and initialization
- Smart remote origin setup
- Default branch configuration to
main - Comprehensive repository state validation
- Interactive branch selection with current branch display
- Auto-suggested branch names using format:
type/description-YYYY-MM-DD - Support for direct main branch commits with
--no-branch - Safe branch creation and switching
- Detects unstaged changes automatically
- Stages all files when no staged changes found
- Progress feedback during staging operations
- Robust error handling for staging failures
- Manual mode (default): Uses conventional commit format
type(scope): description - AI mode (--genie): Powered by Google Gemini 2.0 Flash model
- Professional Conventional Commits specification compliance
- Intelligent analysis of code diffs for contextual commit messages
- Graceful fallback to manual mode when AI fails
- Support for all conventional commit types and scopes
-
When you donβt pass
--typeand youβre not using--genie, GitGenie analyzes your staged changes and picks a suitable commit type (e.g.,fix,docs,refactor). -
Youβll see a log like:
π§ Auto-detected commit type: fix -
Override any time by passing
--type <type>explicitly.
- Interactive push confirmation with retry logic
- Automated merge-to-main functionality with
--push-to-main - Feature branch cleanup after successful merges
- Remote branch synchronization and management
- Network failure resilience with automatic retries
- Clean, corporate-friendly messaging
- Real-time progress indicators with spinners
- Colored output for better readability
- Comprehensive error handling with helpful messages
- Cross-platform compatibility
- @google/generative-ai (latest): Google Gemini AI integration
- commander (v14.0.0): CLI argument parsing and command structure
- simple-git (v3.28.0): Git operations and repository management
- inquirer (v12.9.2): Interactive command line prompts
- chalk (v5.5.0): Terminal color and styling
- ora (v8.2.0): Progress spinners and status indicators
- dotenv (v17.2.1): Environment variable management
- Package:
gitgenie-cli - Version:
1.0.0+ - Module Type: ES6 modules
- Global Command:
gg - Entry Point:
index.js - Node Version: 16+ recommended
gg "fix login bug" --osc
gg "fix login bug" --osc --genie
# Navigate to project directory
cd "d:\my\GUNJAN\Git Butler"
# Install dependencies (if needed)
npm install
# Basic commit with manual message (default behavior)
gg "add new feature"
# Commit with AI-generated message using Gemini
gg "fix authentication bug" --genie
# Commit with specific type and scope
gg "fix authentication bug" --type fix --scope auth
# Commit with AI, specific type and scope
gg "optimize database queries" --type perf --scope db --genie
# Commit directly to main branch (no AI)
gg "update documentation" --no-branch
# Automatically merge to main and push
gg "add user dashboard" --type feat --push-to-main
# Initialize new repo with remote
gg "initial commit" --remote https://github.com/username/repo.git --no-branch# Run with interactive prompts
gg "implement user management"
# The tool will ask:
# 1. Current branch is "main". Where do you want to commit?
# - Commit to current branch (main)
# - Create a new branch
#
# 2. If creating new branch:
# Enter new branch name: feat/implement-user-management-2025-09-01
#
# 3. After commit:
# Do you want to push branch "feat/implement-user-management-2025-09-01" to remote? (Y/n)# Testing the CLI tool functionality with AI
gg "test file modifications" --type test --scope cli --genie
# Bug fix with specific scope (manual commit)
gg "resolve merge conflicts" --type fix --scope git
# Feature addition with AI-generated commit message
gg "add interactive branch selection" --type feat --scope branch --genie
# Documentation update directly to main
gg "update README with examples" --type docs --no-branch
# Performance improvement with AI and auto-merge to main
gg "optimize database queries" --type perf --scope db --genie --push-to-main# First commit to a new repo, main branch, manual commit
gg "initial commit" --no-branch --remote https://github.com/username/git-genie.git
# Commit to existing repo, interactive branch selection & AI commit
gg "add interactive branch selection" --type feat --scope commit --genie
# Commit to current branch directly with manual message
gg "fix typo in README" --no-branch- CLI parses user input and options.
- Initializes Git repository if none exists.
- Adds remote origin if provided.
- Checks for existing commits.
- Prompts the user to choose the branch (interactive) or commits directly to main if
--no-branch.- If
--oscis used and new branch is selected, prompts for issue number and generates branch name astype/#issue-shorttitle(shorttitle by Gemini if --genie, otherwise from message)
- If
- Stages all files if needed.
- Generates commit message (AI with
--genieflag or manual by default). - Commits the changes.
- Handles push logic based on
--push-to-mainflag or interactive prompts. - Optionally merges to main branch and pushes with retry logic.
- Provides detailed console feedback for every step.
- Repository Check: Verifies if current directory is a Git repo, initializes if not
- Remote Setup: Adds remote origin if provided via
--remoteflag - Commit History Check: Determines if repository has existing commits
- Branch Decision:
- If
--no-branchor no commits: commits to main - Otherwise: interactive prompt to choose current branch or create new one
- If
- File Staging: Checks for staged changes, auto-stages all files if none found
- Commit Message Generation:
- Uses Gemini AI to analyze diff and generate commit message
- Falls back to manual format if AI disabled or fails
- Commit Execution: Commits staged files with generated message
- Push Confirmation: Asks user if they want to push to remote
- Push with Retry: Attempts to push with retry logic for network failures
β
Automated Git Workflows - Reduces manual Git command typing
β
AI-Generated Commit Messages - Professional, contextual commit messages
β
Open Source Contribution Helper - Issue-based branch naming for open source PRs
β
Interactive Branch Management - User-friendly branch creation and switching
β
Smart Error Handling - Graceful fallbacks and retry mechanisms
β
Professional Formatting - Conventional Commit standards
β
Colored Output - Clear visual feedback with chalk
β
Spinner Feedback - Real-time progress indicators
β
Flexible Configuration - Multiple CLI options for different workflows
# Test basic functionality
gg "test basic functionality" --no-ai --no-branch
# Test AI commit generation
gg "test AI commit generation" --type test
# Test branch creation
gg "test branch creation" --type feat --scope testing
# Test error handling (no changes)
gg "test no changes scenario" --no-branch
# Test with different commit types
gg "test documentation" --type docs
gg "test bug fix" --type fix
gg "test refactoring" --type refactor- If no remote is configured, the CLI offers to add one before pushing. You can skip this and push later.
- Unknown commands provide helpful suggestions.
GitGenie is open source, and contributions are welcome π This section is meant for first-time contributors who want to understand how the project works and how to get started safely.
At a high level, GitGenie works as follows:
- Reads CLI input and flags using commander
- Validates the current directory as a Git repository (or initializes one)
- Handles branch selection (interactive or non-interactive)
- Stages files automatically when needed
- Generates a commit message:
- Manually (default)
- Or using Google Gemini when --genie is enabled
- Commits changes
- Optionally pushes or merges to main
Most logic lives inside index.js, which orchestrates Git operations using simple-git and user prompts via inquirer.
You do not need to understand the full internal flow to contribute documentation or small fixes.
1οΈβ£ Fork the Repository
Click Fork on GitHub to create your own copy of the repository.
2οΈβ£ Clone Your Fork
git clone https://github.com/<your-username>/gitgenie-cli.git
cd gitgenie-cli3οΈβ£ Install Dependencies
npm install4οΈβ£ Link the CLI Locally
- This allows you to run the gg command while developing:
npm link- Verify installation:
gg --help
If the help output appears, GitGenie is running locally β
Itβs recommended to test GitGenie inside a temporary Git repository.
mkdir test-repo
cd test-repo
git initExample test commands:
gg "test basic commit" --no-branch
gg "test ai commit" --genie
gg "test branch flow" --type feat
gg "test no changes" --no-branch
- Commands execute without crashing
- Prompts behave as expected
- No unintended Git changes occur
If you find a bug or want to suggest an improvement:
- Go to the Issues tab on GitHub
- Click New Issue
- Choose the appropriate issue template (if available)
- Clearly describe:
- What you expected
- What actually happened
- Steps to reproduce (if applicable)
- Well-described issues help maintainers respond faster.
- Branching
- Do not commit directly to main.
- Create a feature branch:
git checkout -b docs/improve-readme - Commit Your Changes
git add .git commit -m "docs: improve contributor onboarding section"
- Push and Open a PR
git push origin docs/improve-readme
- Then open a Pull Request on GitHub:
- Base branch β main
- Compare branch β your feature branch
- Fill out the PR template and clearly explain what you changed and why.
To keep contributions focused:
β Do NOT add new CLI features β Do NOT refactor existing CLI logic β Do NOT change default behaviors without discussion
β Documentation improvements β Bug fixes β Small usability improvements
If unsure, open an issue first and ask.
If you get stuck:
- Comment on the issue youβre working on
- Ask questions in the PR
- Share error messages or screenshots
- We would rather help than guess.
-
Add interactive guided mode for beginners (e.g., --wizard)
-
Add command autocomplete and suggestions
-
Add onboarding welcome for first-time users
-
Add undo/redo for git actions
-
Add more help and examples in CLI output
-
Can implement last-used branch suggestion for faster workflow.
-
Optional integration with other AI models for commit suggestions.
-
Ability to include commit templates for faster conventional commit adherence.
-
Extend CLI with commands like
git-genie status,git-genie log, etc. -
Add support for conventional commit scopes validation.
-
Implement configuration file for default settings.
-
Add git hooks integration for automated workflows.
This document captures the current state of GitGenie CLI, including all features, functionality, CLI behavior, project structure, and comprehensive usage examples. It serves as a complete reference for users and developers working with or extending the tool.