Thank you for considering contributing to git gtr! This document provides guidelines and instructions for contributing.
Before creating an issue, please:
- Search existing issues to avoid duplicates
- Provide a clear description of the problem
- Include your environment details:
- OS and version (macOS, Linux distro, Windows Git Bash)
- Git version
- Shell (bash, zsh, fish)
- Steps to reproduce the issue
- Expected vs actual behavior
We welcome feature suggestions! Please:
- Check existing issues for similar requests
- Describe the use case - why is this needed?
- Propose a solution if you have one in mind
- Consider backwards compatibility and cross-platform support
git-worktree-runner/
├── bin/git-gtr # Main executable (sources libs, dispatches commands)
├── bin/gtr # Convenience wrapper (exec bin/git-gtr)
├── lib/ # Core functionality
│ ├── ui.sh # User interface (logging, prompts)
│ ├── config.sh # Configuration (git-config wrapper)
│ ├── platform.sh # OS-specific utilities
│ ├── core.sh # Git worktree operations
│ ├── copy.sh # File copying logic
│ ├── hooks.sh # Hook execution
│ ├── provider.sh # GitHub/GitLab provider detection
│ ├── adapters.sh # Adapter registries, builders, and loaders
│ └── commands/ # Command handlers (one file per command)
│ ├── create.sh # cmd_create + helpers
│ ├── remove.sh # cmd_remove
│ ├── rename.sh # cmd_rename
│ ├── ... # (16 files total, one per command)
│ └── help.sh # cmd_help
├── adapters/ # Custom adapter overrides (non-registry)
│ ├── editor/nano.sh # nano (custom terminal behavior)
│ └── ai/ # claude.sh, cursor.sh (custom logic)
├── completions/ # Shell completions (bash, zsh, fish)
└── templates/ # Example configs and scripts
- Bash requirement: All scripts use Bash (use
#!/usr/bin/env bash) - Set strict mode: Use
set -eto exit on errors - Quote variables: Always quote variables:
"$var" - Use local variables: Declare function-local vars with
local - Error handling: Check return codes and provide clear error messages
- Target Bash 3.2+: Code runs on Bash 3.2+ (macOS default), but Bash 4.0+ features (like globstar) are allowed where appropriate
- Function names: Use
snake_casefor functions - Variable names: Use
snake_casefor variables - Constants: Use
UPPER_CASEfor constants/env vars - Indentation: 2 spaces (no tabs)
- Line length: Keep lines under 100 characters when possible
- Comments: Add comments for complex logic
#!/usr/bin/env bash
# Brief description of what this file does
# Function description
do_something() {
local input="$1"
local result
if [ -z "$input" ]; then
log_error "Input required"
return 1
fi
result=$(some_command "$input")
printf "%s" "$result"
}Most editors follow a standard pattern and can be added as a registry entry in lib/adapters.sh (no separate file needed).
Option A: Registry entry (preferred for standard editors)
Add a line to _EDITOR_REGISTRY in lib/adapters.sh:
yourname|yourcmd|standard|YourEditor not found. Install from https://...|flags
Format: name|cmd|type|err_msg|flags where:
type:standard(GUI app) orterminal(runs in current terminal)flags: comma-separated —workspace(supports .code-workspace files),background(run in background)
Option B: Custom adapter file (for editors with non-standard behavior)
Create adapters/editor/yourname.sh implementing editor_can_open() and editor_open(). See adapters/editor/nano.sh for an example.
Also update: README.md, all three completion files, help text in lib/commands/help.sh.
Option A: Registry entry (preferred for standard CLI tools)
Add a line to _AI_REGISTRY in lib/adapters.sh:
yourname|yourcmd|YourTool not found. Install with: ...|Extra info line 1;Extra info line 2
Format: name|cmd|err_msg|info_lines (info lines are semicolon-separated).
Option B: Custom adapter file (for tools with non-standard behavior)
Create adapters/ai/yourname.sh implementing ai_can_start() and ai_start(). See adapters/ai/claude.sh for an example.
Also update: README.md, completions, help text.
For changes to core functionality (lib/*.sh):
- Discuss first: Open an issue to discuss the change
- Maintain compatibility: Avoid breaking existing configs
- Add tests: Provide test cases or manual testing instructions
- Update docs: Update README.md and help text
- Consider edge cases: Think about error conditions
Run the test suite before submitting PRs:
bats tests/ # Run all tests
bats tests/copy_safety.bats # Run a specific test fileCI runs ShellCheck + BATS automatically on all PRs (.github/workflows/lint.yml).
Please also test your changes manually on:
- macOS (if available)
- Linux (Ubuntu, Fedora, or Arch recommended)
- Windows Git Bash (if available)
- Create worktree with branch name
- Create worktree with branch containing slashes (e.g., feature/auth)
- Create from remote branch
- Create from local branch
- Create new branch
- Open in editor (if testing adapters)
- Run AI tool (if testing adapters)
- Remove worktree by branch name
- List worktrees
- Test configuration commands
- Test completions (tab completion works)
- Test
git gtr go 1for main repo - Test
git gtr go <branch>for worktrees
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes
- Test thoroughly (see checklist above)
- Update documentation (README.md, help text, etc.)
- Commit with clear messages:
- Use present tense: "Add feature" not "Added feature"
- Be descriptive: "Add VS Code adapter" not "Add adapter"
- Push to your fork
- Open a Pull Request with:
- Clear description of changes
- Link to related issues
- Testing performed
- Screenshots/examples if applicable
<type>: <short description>
<optional longer description>
<optional footer>
Types:
feat: New featurefix: Bug fixdocs: Documentation changesrefactor: Code refactoring (no functional changes)test: Adding or updating testschore: Maintenance tasks
Examples:
feat: add JetBrains IDE adapter
Add support for opening worktrees in IntelliJ, PyCharm, and other
JetBrains IDEs via the 'idea' command.
Closes #42
fix: handle spaces in worktree paths
Properly quote paths in all commands to support directories with spaces.
When contributing, please keep these principles in mind:
- Cross-platform first - Code should work on macOS, Linux, and Windows
- No external dependencies - Avoid requiring tools beyond git and basic shell
- Config over code - Prefer configuration over hardcoding behavior
- Fail safely - Validate inputs and provide clear error messages
- Stay modular - Keep functions small and focused
- User-friendly - Prioritize good UX and clear documentation
- Be respectful and constructive
- Help others who are learning
- Share knowledge and best practices
- Have fun! This is a community project
- Open an issue for questions
- Check existing issues and docs first
- Be patient - maintainers are volunteers
Thank you for contributing! 🎉