git-workflow 0.1.1

Git workflow CLI - type-safe worktree-aware git operations with GitHub integration
Documentation

git-workflow

A type-safe Git workflow CLI with worktree support and GitHub integration.

Features

  • Type-safe branch protection - Prevents accidental deletion of protected branches (main, master, home)
  • Git worktree aware - Automatically detects and works with git worktrees
  • GitHub integration - Fetches PR information to make informed decisions about branch operations
  • Smart state detection - Detects repository state and suggests next actions
  • Minimal dependencies - Built with Rust for fast execution

Installation

From crates.io

cargo install git-workflow

From source

git clone https://github.com/zawakin/git-workflow.git
cd git-workflow
cargo install --path .

Usage

The CLI is invoked using the gw command.

Commands

gw home

Switch to home branch and sync with origin/main.

gw home

gw new <branch>

Create a new branch from origin/main.

gw new feature/add-login
gw new fix/memory-leak

gw status

Show current repository state including:

  • Current branch and sync status
  • Working directory state
  • Suggested next action
gw status

gw cleanup [branch]

Delete a merged branch and return to home. Uses GitHub CLI to verify PR merge status.

gw cleanup              # cleanup current branch
gw cleanup feature/old  # cleanup specific branch

gw pause [message]

Create a WIP commit with all changes and return to home branch.

gw pause
gw pause "waiting for API review"

gw abandon

Discard all changes and return to home branch.

gw abandon

gw undo

Undo the last commit (soft reset to HEAD~1).

gw undo

gw sync

After a base PR is merged, update the base to main and rebase.

gw sync

Global Options

  • -v, --verbose - Show git commands being executed
gw -v status
gw --verbose cleanup

Prerequisites

Workflow Example

# Start new feature
gw new feature/user-auth

# ... work on feature ...

# Need to switch context? Pause work
gw pause "blocked on API changes"

# Switch to another task
gw new fix/urgent-bug

# ... fix the bug ...

# Clean up after PR is merged
gw cleanup

# Resume previous work
git checkout feature/user-auth

# Check status anytime
gw status

Home Branch

The "home branch" is determined by:

  1. In a git worktree: the worktree directory name
  2. Otherwise: main (or master if main doesn't exist)

License

Licensed under either of:

at your option.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.