{"id":31766400,"url":"https://github.com/knqyf263/gh-worktree","last_synced_at":"2025-10-10T00:46:46.576Z","repository":{"id":301099369,"uuid":"1007701036","full_name":"knqyf263/gh-worktree","owner":"knqyf263","description":"GitHub CLI extension for managing git worktrees with pull requests","archived":false,"fork":false,"pushed_at":"2025-07-22T14:03:37.000Z","size":50,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-22T16:08:42.709Z","etag":null,"topics":["cli","github"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/knqyf263.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-24T11:54:27.000Z","updated_at":"2025-07-22T14:03:40.000Z","dependencies_parsed_at":"2025-06-25T06:37:56.290Z","dependency_job_id":"d7b45042-4571-4031-b485-189c45b64229","html_url":"https://github.com/knqyf263/gh-worktree","commit_stats":null,"previous_names":["knqyf263/gh-worktree"],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/knqyf263/gh-worktree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knqyf263%2Fgh-worktree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knqyf263%2Fgh-worktree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knqyf263%2Fgh-worktree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knqyf263%2Fgh-worktree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/knqyf263","download_url":"https://codeload.github.com/knqyf263/gh-worktree/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/knqyf263%2Fgh-worktree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002343,"owners_count":26083356,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","github"],"created_at":"2025-10-10T00:46:45.044Z","updated_at":"2025-10-10T00:46:46.571Z","avatar_url":"https://github.com/knqyf263.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# gh-worktree\n\nA GitHub CLI extension for managing git worktrees with pull requests.\n\nInstead of checking out pull requests in your current directory, this extension creates dedicated worktrees in a separate directory with a clear naming convention (`../repo-name-pr1234`).\n\n## Features\n\n- 🌳 **Create worktrees for PRs** - Each PR gets its own isolated working directory\n- 🔄 **Switch between worktrees** - Quick navigation between different PR worktrees\n- 🗑️ **Clean removal** - Remove worktrees and associated branches in one command\n- 📋 **List all PR worktrees** - See all your PR worktrees at a glance\n- 🎯 **Interactive selection** - Use arrow keys and filtering to select PRs\n\n## Installation\n\n```bash\ngh extension install knqyf263/gh-worktree\n```\n\n## Commands\n\n### `gh worktree pr checkout`\n\nCreate a new worktree for a pull request.\n\n```bash\n# Interactive selection from open PRs\ngh worktree pr checkout\n\n# Checkout specific PR by number\ngh worktree pr checkout 1234\n\n# Checkout specific PR by URL\ngh worktree pr checkout https://github.com/owner/repo/pull/1234\n```\n\n**Example Output:**\n```\nCreated worktree for #1234 at ../repo-name-pr1234\nTitle: Add new feature for user management\n```\n\n### `gh worktree pr list`\n\nList all existing PR worktrees.\n\n```bash\ngh worktree pr list\n```\n\n**Example Output:**\n```\nPR worktrees:\n  #1234\tfeature-branch\tAdd new feature for user management\t../repo-name-pr1234\n  #5678\tbugfix-branch\tFix critical security vulnerability\t../repo-name-pr5678\n```\n\n### `gh worktree pr remove`\n\nRemove a PR worktree and its associated branch.\n\n```bash\n# Interactive selection\ngh worktree pr remove\n\n# Remove specific PR worktree\ngh worktree pr remove 1234\n```\n\n**Example Output:**\n```\nRemoved worktree for #1234 at ../repo-name-pr1234\nTitle: Add new feature for user management\n```\n\n### `gh worktree pr switch`\n\nSwitch to an existing PR worktree directory.\n\n```bash\n# Interactive selection\ngh worktree pr switch\n\n# Switch to specific PR worktree\ngh worktree pr switch 1234\n\n# Shell mode (outputs path only)\ngh worktree pr switch --shell 1234\n```\n\n## Directory Structure\n\nThe extension creates worktrees in the parent directory of your current repository:\n\n```\nparent-directory/\n├── my-repo/                    # Original repository\n├── my-repo-pr1234/            # PR #1234 worktree\n├── my-repo-pr5678/            # PR #5678 worktree\n└── my-repo-pr9999/            # PR #9999 worktree\n```\n\n## Shell Integration\n\nFor the best experience, add these shell functions to your `~/.bashrc` or `~/.zshrc`:\n\n```bash\n# Quick worktree switcher\nghws() { \n  local target=$(gh worktree pr switch --shell \"$@\")\n  [ -n \"$target\" ] \u0026\u0026 cd \"$target\"\n}\n\n# Checkout and cd into new worktree\nghwc() { \n  local target=$(gh worktree pr checkout --shell \"$@\")\n  [ -n \"$target\" ] \u0026\u0026 cd \"$target\"\n}\n```\n\n**Usage:**\n```bash\n# Interactive selection and switch\nghws\n\n# Switch to specific PR\nghws 1234\n\n# Interactive checkout and cd\nghwc\n\n# Checkout specific PR and cd\nghwc 1234\n```\n\n## How It Works\n\n1. **Worktree Creation**: Creates git worktrees in `../repo-name-pr{number}` format\n2. **Branch Management**: Sets up proper remote tracking and handles cross-repository PRs similar to `gh pr checkout`\n3. **Clean Removal**: Removes both worktree and branch when cleaning up\n\n## Comparison with `gh pr checkout`\n\n| Feature          | `gh pr checkout`   | `gh worktree pr checkout`   |\n|------------------|--------------------|-----------------------------|\n| Location         | Current directory  | Separate worktree directory |\n| Multiple PRs     | Requires switching | Parallel development        |\n| Branch conflicts | Possible           | Isolated per worktree       |\n\n## Advanced Usage\n\n### Working with Multiple PRs\n\n```bash\n# Checkout multiple PRs for parallel development\ngh worktree pr checkout 1234\ngh worktree pr checkout 5678\n\n# List all active worktrees\ngh worktree pr list\n\n# Switch between them quickly\nghws 1234  # Switch to PR 1234\nghws 5678  # Switch to PR 5678\n```\n\n### Cross-Repository PRs\n\nThe extension handles PRs from forks correctly:\n\n```bash\n# This works even if the PR is from a fork\ngh worktree pr checkout 1234\n```\n\nThe extension will:\n- Set up appropriate remotes\n- Configure push/pull settings\n- Handle `maintainer_can_modify` permissions\n\n## Requirements\n\n- [GitHub CLI](https://cli.github.com/) (gh)\n- Git with worktree support (Git 2.5+)\n- Access to the repository (for API calls)\n\n## Contributing\n\nContributions are welcome! Please feel free to submit issues and pull requests.\n\n## License\n\nThis project is licensed under the MIT License.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknqyf263%2Fgh-worktree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fknqyf263%2Fgh-worktree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fknqyf263%2Fgh-worktree/lists"}