A safe git workflow automation CLI tool for engineering teams. gitext replaces manual git workflow steps with safe, repeatable commands that enforce branch protection rules and prevent accidental production contamination.
- Safe branch management: Enforces rules to prevent accidental production contamination from stage
- Automated workflows: Common git operations simplified into single commands
- Branch protection: Pre-push hooks prevent direct pushes to protected branches
- CI integration: Run configured CI checks before creating PRs
- Smart suggestions: Commands suggest next steps based on current state
- AI-powered commit messages: Generate commit messages automatically using AI (OpenAI or OpenRouter) following Conventional Commits specification
Linux (amd64):
curl -L https://github.com/imemir/gitext/releases/latest/download/gitext-linux-amd64 -o gitext
chmod +x gitext
sudo mv gitext /usr/local/bin/Linux (arm64):
curl -L https://github.com/imemir/gitext/releases/latest/download/gitext-linux-arm64 -o gitext
chmod +x gitext
sudo mv gitext /usr/local/bin/macOS (amd64):
curl -L https://github.com/imemir/gitext/releases/latest/download/gitext-darwin-amd64 -o gitext
chmod +x gitext
sudo mv gitext /usr/local/bin/macOS (arm64 / Apple Silicon):
curl -L https://github.com/imemir/gitext/releases/latest/download/gitext-darwin-arm64 -o gitext
chmod +x gitext
sudo mv gitext /usr/local/bin/Windows (amd64):
Invoke-WebRequest -Uri https://github.com/imemir/gitext/releases/latest/download/gitext-windows-amd64.exe -OutFile gitext.exe
# Add to PATH or move to desired locationWindows (arm64):
Invoke-WebRequest -Uri https://github.com/imemir/gitext/releases/latest/download/gitext-windows-arm64.exe -OutFile gitext.exe
# Add to PATH or move to desired locationgit clone https://github.com/imemir/gitext.git
cd gitext
go build -o gitext ./cmd/gitext
sudo mv gitext /usr/local/bin/gitext --helpgitext supports shell completion for bash, zsh, fish, and PowerShell.
Bash:
source <(gitext completion bash)
# Add to ~/.bashrc or ~/.bash_profile for persistenceZsh:
source <(gitext completion zsh)
# Add to ~/.zshrc for persistenceFish:
gitext completion fish | source
# Add to ~/.config/fish/config.fish for persistencePowerShell:
gitext completion powershell | Out-String | Invoke-Expression
# Add to your PowerShell profile for persistence- Initialize gitext in your repository:
gitext init --install-hooksThis creates a .gitext configuration file and optionally installs git hooks.
- Check your current status:
gitext status- Start a new feature branch:
gitext start feature --ticket KWS-123 --slug retry-policy --from stage- Optional: Setup AI for commit messages:
gitext ai setupAfter setup, you can use gitext commit instead of git commit to automatically generate commit messages.
The .gitext file is a YAML configuration file placed in your repository root. Here's an example:
branch:
production: "production"
stage: "stage"
naming:
feature: "feature/*"
hotfix: "hotfix/*"
merge:
requireRetargetForProdFromStage: true
ci:
stage:
- "go test ./..."
- "go vet ./..."
production:
- "go test ./..."
- "go vet ./..."
- "go build ./..."
pr:
templatePath: ".github/pull_request_template.md" # optional
remote:
name: "origin"- branch.production: Name of the production branch (default: "production")
- branch.stage: Name of the stage branch (default: "stage")
- naming.feature: Pattern for feature branch names (default: "feature/*")
- naming.hotfix: Pattern for hotfix branch names (default: "hotfix/*")
- merge.requireRetargetForProdFromStage: Enforce retargeting workflow (default: true)
- ci.stage: Array of shell commands to run before PRs to stage
- ci.production: Array of shell commands to run before PRs to production
- pr.templatePath: Optional path to PR template file (relative to repo root)
- remote.name: Git remote name (default: "origin")
AI configuration is stored in ~/.gitext/config.yaml (global configuration, not per-repository). This file is created automatically when you run gitext ai setup.
Example configuration:
provider: openai # or "openrouter"
openai:
api_key: sk-...
model: gpt-4o
openrouter:
api_key: sk-...
model: google/gemini-flash-1.5-8b
use_free_model: trueSecurity:
- The config file is created with permissions
0600(read/write for owner only) - API keys are masked when displayed (
gitext ai config) - You can reconfigure anytime with
gitext ai setup
Initialize gitext configuration in the current repository.
gitext init [--install-hooks]- Creates
.gitextconfiguration file if it doesn't exist --install-hooks: Install pre-push git hooks to prevent direct pushes to protected branches
Show current git status and suggest next steps.
gitext statusDisplays:
- Current branch
- Working tree state (clean/dirty)
- Ahead/behind status vs remote, stage, and production
- Suggested next command
Safely sync a branch with its remote using fast-forward only.
gitext sync stage
gitext sync production- Fetches from remote
- Pulls with
--ff-only(fails if fast-forward not possible) - Suggests update command if branch has diverged
Create a new feature branch from stage or production.
gitext start feature --ticket KWS-123 --slug retry-policy --from stage- Validates branch name matches configured pattern
- Creates branch from specified source (stage or production)
- Checks out the new branch
Update current feature branch with changes from stage or production.
gitext update feature --with stage --mode rebase
gitext update feature --with production --mode merge--with: Source branch (stage or production)--mode: Update method (rebase or merge, default: rebase)
Retarget a feature branch from stage onto production.
gitext retarget feature --onto production --from stageSafety features:
- Validates current branch is a feature branch (unless
--override) - Detects shared branches (multiple authors) and requires
--i-know-what-im-doing - Uses
git rebase --ontoto rewrite history - Warns about force push requirements
Flags:
--override: Allow retargeting non-feature branches--i-know-what-im-doing: Bypass shared branch safety check
Run CI checks and generate PR text.
gitext prepare pr --to stage
gitext prepare pr --to production- Runs configured CI commands for the target branch
- Generates PR text with branch info, ticket, and commit summary
- Prints PR text to stdout
- Uses template if configured
Clean up merged local branches.
gitext cleanup [--hard]- Lists branches merged into stage or production
- Dry-run by default (shows what would be deleted)
--hard: Actually delete branches- Skips protected branches (stage/production)
Generate shell completion scripts for bash, zsh, fish, or PowerShell.
gitext completion bash
gitext completion zsh
gitext completion fish
gitext completion powershellSee the Shell Completion section for installation instructions.
gitext includes AI-powered features for generating commit messages automatically. The AI analyzes your code changes and generates commit messages following the Conventional Commits specification.
Before using AI features, you need to configure an AI provider:
gitext ai setupThis interactive command will:
- Let you choose between OpenAI or OpenRouter
- Prompt for your API key (input is hidden)
- Let you select a model
- Test the connection
- Save configuration to
~/.gitext/config.yaml
OpenAI Options:
gpt-4o(default - recommended)gpt-4o-mini(faster, cheaper)gpt-4-turbogpt-3.5-turbo(cheapest)- Custom model
OpenRouter Options:
- Free models:
google/gemini-flash-1.5-8b,qwen/qwen-2.5-7b-instruct,mistralai/mistral-7b-instruct-v0.2 - Custom model (any model supported by OpenRouter)
View your current AI configuration or test the connection.
# View configuration
gitext ai config
# Test connection
gitext ai config --testDisplays:
- Current provider (OpenAI or OpenRouter)
- Masked API key (for security)
- Selected model
- Configuration file path
Generate a commit message using AI and create the commit.
# Stage your changes first
git add .
# Generate commit message with AI and commit
gitext commit
# Use a custom message instead
gitext commit --message "fix: custom commit message"How it works:
- Checks for staged changes
- Gets the diff of staged changes
- Sends diff to AI provider
- Generates commit message following Conventional Commits format
- Shows the generated message and asks for confirmation
- Creates the commit if confirmed
Example output:
→ Getting staged changes
→ Generating commit message with AI...
✓ Generated commit message:
feat(auth): add password reset functionality
Create commit with this message? [Y/n]: y
→ Creating commit
✓ Commit created successfully
Note: The AI analyzes your code changes and generates messages in the format type(scope): description where:
type: feat, fix, docs, style, refactor, perf, test, chore, etc.scope: optional, the area affected (e.g., auth, api, ui)description: brief summary in imperative mood
- Start a feature from stage:
gitext start feature --ticket KWS-123 --slug new-feature --from stage- Make changes and commit with AI:
git add .
gitext commitOr use traditional git commit:
git add .
git commit -m "Add new feature"- Update with latest stage changes:
gitext update feature --with stage --mode rebase- Prepare PR to stage:
gitext prepare pr --to stage- After PR is merged to stage, retarget for production:
gitext retarget feature --onto production --from stage- Prepare PR to production:
gitext prepare pr --to production- Start hotfix from production:
gitext start feature --ticket HOTFIX-456 --slug critical-fix --from production- Make fix and commit with AI:
git add .
gitext commitOr use traditional git commit:
git add .
git commit -m "Fix critical issue"- Prepare PR to production:
gitext prepare pr --to production- After merge, sync production to stage:
gitext sync production
gitext sync stage- No destructive operations without flags: Commands require explicit flags (
--hard,--force,--i-know-what-im-doing) for destructive operations - Pre-push hooks: Blocks direct pushes to protected branches (unless CI user detected)
- Working tree checks: Most commands fail if working tree is dirty
- Fast-forward only: Default to safe merge strategies (
--ff-only) - Shared branch detection: Warns/blocks retargeting shared branches
- Dry-run mode: Global
--dry-runflag shows what would be done without executing
--dry-run: Show what would be done without executing--verbose: Show detailed git command output
Commit or stash your changes first:
git commit -am "Your message"
# or
git stashYour branch has diverged. Update it first:
gitext update feature --with stageThe branch has multiple authors and retargeting would rewrite shared history. Use --i-know-what-im-doing if you're certain:
gitext retarget feature --onto production --from stage --i-know-what-im-doingAdd the remote:
git remote add origin <repository-url>Set up AI provider first:
gitext ai setupPossible causes:
- Invalid API key: Run
gitext ai config --testto verify - Network issues: Check your internet connection
- API rate limits: Wait a moment and try again
- No staged changes: Stage your changes with
git addfirst
- Verify your API key is correct
- Check if you have sufficient API credits/quota
- For OpenRouter: Ensure the model name is correct
- Try running
gitext ai setupagain to reconfigure
Contributions are welcome! Please ensure all tests pass and follow the existing code style.
MIT License - see LICENSE file for details.