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
From source
Usage
The CLI is invoked using the gw command.
Commands
gw home
Switch to home branch and sync with origin/main.
gw new <branch>
Create a new branch from origin/main.
gw status
Show current repository state including:
- Current branch and sync status
- Working directory state
- Suggested next action
gw cleanup [branch]
Delete a merged branch and return to home. Uses GitHub CLI to verify PR merge status.
gw pause [message]
Create a WIP commit with all changes and return to home branch.
gw abandon
Discard all changes and return to home branch.
gw undo
Undo the last commit (soft reset to HEAD~1).
gw sync
After a base PR is merged, update the base to main and rebase.
Global Options
-v, --verbose- Show git commands being executed
Prerequisites
- Git
- GitHub CLI (gh) - Required for
cleanupandsynccommands
Workflow Example
# Start new feature
# ... work on feature ...
# Need to switch context? Pause work
# Switch to another task
# ... fix the bug ...
# Clean up after PR is merged
# Resume previous work
# Check status anytime
Home Branch
The "home branch" is determined by:
- In a git worktree: the worktree directory name
- Otherwise:
main(ormasterif main doesn't exist)
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.