{"id":45008677,"url":"https://github.com/bjester/gh-worktree","last_synced_at":"2026-04-02T17:08:36.644Z","repository":{"id":337276629,"uuid":"1152933111","full_name":"bjester/gh-worktree","owner":"bjester","description":"A tool and github CLI extension for managing worktrees","archived":false,"fork":false,"pushed_at":"2026-03-28T23:25:54.000Z","size":222,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-29T01:44:40.231Z","etag":null,"topics":["cli","developer-tools","gh-extension","github","worktree"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/gh-worktree/","language":"Python","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/bjester.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"bjester","patreon":"BlaineJester"}},"created_at":"2026-02-08T16:52:44.000Z","updated_at":"2026-03-28T23:24:27.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/bjester/gh-worktree","commit_stats":null,"previous_names":["bjester/gh-worktree"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/bjester/gh-worktree","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjester%2Fgh-worktree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjester%2Fgh-worktree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjester%2Fgh-worktree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjester%2Fgh-worktree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bjester","download_url":"https://codeload.github.com/bjester/gh-worktree/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bjester%2Fgh-worktree/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31311215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-02T12:59:32.332Z","status":"ssl_error","status_checked_at":"2026-04-02T12:54:48.875Z","response_time":89,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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","developer-tools","gh-extension","github","worktree"],"created_at":"2026-02-18T23:18:57.492Z","updated_at":"2026-04-02T17:08:36.637Z","avatar_url":"https://github.com/bjester.png","language":"Python","readme":"# gh-worktree\n\n[![Python tests](https://github.com/bjester/gh-worktree/actions/workflows/pytest.yml/badge.svg?branch=main)](https://github.com/bjester/gh-worktree/actions/workflows/pytest.yml)\n[![Build](https://github.com/bjester/gh-worktree/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/bjester/gh-worktree/actions/workflows/build.yml)\n[![PyPI](https://img.shields.io/pypi/v/gh-worktree.svg?color=blue)](https://pypi.org/project/gh-worktree/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org)\n\nA CLI tool that helps you manage Git worktrees. Built as a GitHub CLI (`gh`) extension, but works standalone.\n\n**Dependencies:** `git`, [`gh`](https://cli.github.com/)\n\n---\n\n## Table of Contents\n\n- [Quick Start](#quick-start)\n- [Capabilities](#capabilities)\n- [How It Works](#how-it-works)\n  - [Directory Structure](#directory-structure)\n  - [Hooks](#hooks)\n  - [Templates](#templates)\n- [Commands](#commands)\n  - [init](#commands-init)\n  - [create](#commands-create)\n  - [checkout](#commands-checkout)\n  - [remove](#commands-remove)\n  - [install](#commands-install)\n  - [version](#commands-version)\n- [Installation](#installation)\n- [AI Disclosure](#ai-disclosure)\n- [License](#license)\n\n---\n\n## Quick Start\n\n```bash\npip install gh-worktree\n```\n\nOr with uv:\n\n```bash\nuvx gh-worktree\n```\n\nOr download the PEX file from the [releases page](https://github.com/bjester/gh-worktree/releases).\n\nSee [recipes](https://github.com/bjester/gh-worktree-recipes) for hooks and templates.\n\n---\n\n## Capabilities\n\n| Feature | Description |\n|---------|-------------|\n| **Bare repository initialization** | Clean separation of git metadata from worktrees |\n| **Lifecycle hooks** | Custom scripts at key points with checksum validation |\n| **Global + project config** | Hooks and templates at both levels |\n| **PR worktrees** | Create worktrees directly from GitHub PRs |\n| **Project bootstrapping** | Auto-copy hooks/templates from repo on init |\n| **Worktree templates** | Pre-configured files copied to new worktrees |\n| **Environment variables** | Template variables with allowlist support |\n\n---\n\n## How It Works\n\n### Directory Structure\n\nAfter initializing a repository (e.g., `gh-worktree`):\n\n```\ngh-worktree/\n  .bare/                 # Bare git repository\n  .git                   # Points to .bare/\n  .gh/\n    worktree/\n      hooks/             # Project-level hooks\n      templates/         # Project-level templates\n      config.json        # Project configuration\n  my-new-worktree/       # Created worktrees\n    README.md\n    ...\n```\n\n### Hooks\n\nHooks are executable scripts that run at specific lifecycle points. They can be configured at:\n- **Global level**: `~/.gh/worktree/hooks/` (or parent directories outside the project)\n- **Project level**: `.gh/worktree/hooks/` (copied from repo on init if present)\n\nExecution order: global hooks first, then project hooks.\n\n| Hook | Executes At | Description |\n|------|-------------|-------------|\n| `pre_init` | Global only | Before initializing a repository for worktrees |\n| `post_init` | Global + Project | After initializing a repository for worktrees |\n| `pre_checkout` | Global + Project | Before checking out a PR or existing branch as a worktree |\n| `post_checkout` | Global + Project | After checking out a PR or existing branch as a worktree |\n| `pre_create` | Global + Project | Before creating a new worktree (branch) |\n| `post_create` | Global + Project | After creating a new worktree (branch) |\n| `pre_remove` | Global + Project | Before removing a worktree |\n| `post_remove` | Global + Project | After removing a worktree |\n\nHooks must be executable and allowed (via checksum validation) to run.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eExample: post_create hook\u003c/strong\u003e\u003c/summary\u003e\n\nA hook for this project might look something like:\n\n```bash\n#!/usr/bin/env bash\n\nWORKTREE_NAME=\"$1\"            # Full worktree name\nBASE_REF=\"$2\"                 # Format: remote/branch\nWORKTREE_NAME_NORMALIZED=\"$3\" # Worktree name with non-alphanumeric characters replaced by dashes\n\npushd \"$WORKTREE_NAME\"\n\nuv venv\nuv sync --group dev\nprek install -f\n\npopd\n```\n\n\u003c/details\u003e\n\n### Templates\n\nFiles in `.gh/worktree/templates/` are copied to new worktrees before post-hooks execute.\n\n**Tip:** Add template files to `.gitignore`.\n\nTemplates support environment variable substitution using `${ENVVAR_NAME}` syntax. Allowlist variable names in `~/.gh/worktree/config.json` under `allowed_envvars`.\n\n**Provided variables:**\n\n| Variable | Description |\n|----------|-------------|\n| `REPO_NAME` | Name of the git repository |\n| `REPO_DIR` | Absolute path of the repo / project directory |\n| `WORKTREE_NAME` | Name of the new worktree |\n| `WORKTREE_NAME_NORMALIZED` | Worktree name with non-alphanumeric chars replaced by dashes |\n| `WORKTREE_DIR` | Absolute path of the worktree directory |\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003eExample: JetBrains project name template\u003c/strong\u003e\u003c/summary\u003e\n\nSet a unique project name per worktree in JetBrains IDEs:\n\n**File:** `.gh/worktree/templates/.idea/.name`\n\n```\n${REPO_NAME}.${WORKTREE_NAME_NORMALIZED}\n```\n\n**Result in worktree:** `.idea/.name` contains `gh-worktree.feat-my-branch`\n\n\u003c/details\u003e\n\n---\n\n## Commands\n\nRun `gh-worktree` without any arguments for usage information.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ca id=\"commands-init\"\u003einit\u003c/a\u003e\u003c/strong\u003e — Initialize a repository for worktrees\u003c/summary\u003e\n\n**Spec:** `init \u003crepository_uri\u003e [optional_clone_dir] [--yes]`\n\nInitializes a repository for use with worktrees. Similar to `git clone` — specify a directory name as the second argument, or it defaults to the repository name.\n\n- `--yes`: Automatically execute new or modified hooks without prompting\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ca id=\"commands-create\"\u003ecreate\u003c/a\u003e\u003c/strong\u003e — Create a new worktree\u003c/summary\u003e\n\n**Spec:** `create \u003cworktree_name\u003e [base_ref] [--yes]`\n\nCreates a new worktree. Defaults to the default branch of the GitHub repository. Optionally specify a base reference.\n\n- `--yes`: Automatically execute new or modified hooks without prompting\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ca id=\"commands-checkout\"\u003echeckout\u003c/a\u003e\u003c/strong\u003e — Checkout a PR or branch as a worktree\u003c/summary\u003e\n\n**Spec:** `checkout [--remote=\u003cname\u003e] [--yes] \u003cbranch_name|pr_number|pr_url\u003e`\n\nQuickly create a worktree for a PR or existing branch. Works with fork PRs regardless of remote configuration.\n\n- `--yes`: Automatically execute new or modified hooks without prompting\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ca id=\"commands-remove\"\u003eremove\u003c/a\u003e\u003c/strong\u003e — Remove a worktree\u003c/summary\u003e\n\n**Spec:** `remove [--force] [--yes] \u003cworktree_name\u003e`\n\n**Aliases:** `rm`\n\nRemoves a worktree. Git refuses to delete worktrees with unmerged commits unless `--force` is used.\n\n- `--yes`: Automatically execute new or modified hooks without prompting\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ca id=\"commands-install\"\u003einstall\u003c/a\u003e\u003c/strong\u003e — Install gh-worktree\u003c/summary\u003e\n\n**Spec:** `install [--alias=\u003cname\u003e] [--gh-ext] [--path-bin] [--force]`\n\nInstalls gh-worktree as a GitHub CLI extension or to your PATH. Without options, prompts for installation method.\n\n- `--gh-ext`: Install as `gh` extension\n- `--path-bin`: Install to `~/.local/bin` or `~/bin`\n- `--alias`: Custom name (e.g., `wktr`)\n- `--force`: Overwrite existing installation\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003cstrong\u003e\u003ca id=\"commands-version\"\u003eversion\u003c/a\u003e\u003c/strong\u003e — Show version\u003c/summary\u003e\n\n**Spec:** `version`\n\nOutputs the installed version of gh-worktree.\n\n\u003c/details\u003e\n\n---\n\n## Installation\n\nTested on Linux. Requires Python 3.10+ for PEX.\n\n### As a GitHub CLI extension (`gh`)\n\n1. Download the [latest release](https://github.com/bjester/gh-worktree/releases) binary.\n2. Make executable: `chmod +x gh-worktree`\n3. Install: `./gh-worktree install --gh-ext`\n4. Test: `gh worktree`\n\n### Standalone\n\n1. Download the [latest release](https://github.com/bjester/gh-worktree/releases) binary or PEX.\n2. Make executable: `chmod +x gh-worktree*`\n3. Install: `./gh-worktree install --path-bin` or `./gh-worktree.pex install --path-bin`\n4. Test: `gh-worktree version`\n\n### Aliasing\n\n```bash\n./gh-worktree install --alias=wktr --path-bin\nwktr version\n```\n\n### From source\n\n```bash\ngit clone https://github.com/bjester/gh-worktree.git\ncd gh-worktree\nuv venv\nsource .venv/bin/activate\nuv sync --group dev\nmake dist/gh-worktree\n./dist/gh-worktree install --path-bin\n```\n\n---\n\n## AI Disclosure\n\nLLMs were used in the development of this project, mostly for brainstorming and bootstrapping code, particularly tests. The contribution proportion is roughly 80 / 20, human and AI code respectively. This may change over time as I try out agents!\n\n---\n\n## License\n\n[MIT](LICENSE) :: Copyright 2026 Blaine Jester\n","funding_links":["https://github.com/sponsors/bjester","https://patreon.com/BlaineJester"],"categories":["🆕 Recently Updated"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjester%2Fgh-worktree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbjester%2Fgh-worktree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbjester%2Fgh-worktree/lists"}