{"id":48906155,"url":"https://github.com/jeffersongoncalves/git-worktree-cli","last_synced_at":"2026-04-16T20:03:15.584Z","repository":{"id":351827441,"uuid":"1212585336","full_name":"jeffersongoncalves/git-worktree-cli","owner":"jeffersongoncalves","description":"CLI tool to audit git worktrees and check whether their branches have been merged into the main branch. Includes a clean command to remove merged worktrees.","archived":false,"fork":false,"pushed_at":"2026-04-16T18:00:00.000Z","size":24441,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-16T18:10:23.458Z","etag":null,"topics":["cli","git","git-worktree","laravel-zero","merge-check","phar","php","workspace-cleanup","worktree"],"latest_commit_sha":null,"homepage":"https://github.com/jeffersongoncalves/git-worktree-cli","language":"PHP","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/jeffersongoncalves.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"jeffersongoncalves"}},"created_at":"2026-04-16T14:23:15.000Z","updated_at":"2026-04-16T18:00:04.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/jeffersongoncalves/git-worktree-cli","commit_stats":null,"previous_names":["jeffersongoncalves/git-worktree-cli"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/jeffersongoncalves/git-worktree-cli","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffersongoncalves%2Fgit-worktree-cli","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffersongoncalves%2Fgit-worktree-cli/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffersongoncalves%2Fgit-worktree-cli/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffersongoncalves%2Fgit-worktree-cli/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeffersongoncalves","download_url":"https://codeload.github.com/jeffersongoncalves/git-worktree-cli/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeffersongoncalves%2Fgit-worktree-cli/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31902124,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-16T18:22:33.417Z","status":"ssl_error","status_checked_at":"2026-04-16T18:21:47.142Z","response_time":69,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6: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","git","git-worktree","laravel-zero","merge-check","phar","php","workspace-cleanup","worktree"],"created_at":"2026-04-16T20:03:13.514Z","updated_at":"2026-04-16T20:03:15.559Z","avatar_url":"https://github.com/jeffersongoncalves.png","language":"PHP","readme":"\u003cdiv class=\"filament-hidden\"\u003e\n\n![Git Worktree CLI](https://raw.githubusercontent.com/jeffersongoncalves/git-worktree-cli/main/art/jeffersongoncalves-git-worktree-cli.jpg)\n\n\u003c/div\u003e\n\n# git-worktree-cli\n\nCLI tool to audit git worktrees in a repository and report whether each\nworktree's branch has already been merged into the main branch. Includes\na `clean` command to remove merged worktrees and keep the workspace tidy.\n\nBuilt with [Laravel Zero](https://laravel-zero.com) and modeled on the\nother CLIs in this monorepo.\n\n## Requirements\n\n- PHP `^8.2`\n- `git` available on `PATH`\n- A git repository with at least one linked worktree\n\n## Install\n\n### Global (recommended)\n\n```bash\ncomposer global require jeffersongoncalves/git-worktree-cli\n```\n\nThe binary `git-worktree` will be on your `PATH` as long as Composer's\nglobal `vendor/bin` is in it.\n\n### From source\n\n```bash\ngit clone https://github.com/jeffersongoncalves/git-worktree-cli.git\ncd git-worktree-cli\ncomposer install\n```\n\n## Usage\n\n```bash\n# Audit the current directory (the default command)\ngit-worktree\n\n# Audit a specific repo\ngit-worktree check /path/to/repo\n\n# Force a specific main branch (otherwise auto-detected)\ngit-worktree check --main=develop\n\n# Only show worktree branches that are NOT merged\ngit-worktree check --only-unmerged\n```\n\n### Clean merged worktrees\n\n```bash\n# Preview — doesn't touch anything\ngit-worktree clean --dry-run\n\n# Prompt to confirm, then remove\ngit-worktree clean\n\n# Skip confirmation + also delete the local branch\ngit-worktree clean --yes --delete-branch\n\n# Force removal (worktrees with dirty state, branches with -D)\ngit-worktree clean --yes --delete-branch --force\n\n# Only remove branches directly merged (exclude squash/rebase detection)\ngit-worktree clean --strict\n```\n\n### List worktrees\n\n```bash\ngit-worktree list-worktrees\n```\n\n### Keep the CLI up to date\n\nWhen installed from the released PHAR, self-update from the terminal:\n\n```bash\ngit-worktree self-update          # download and install the latest release\ngit-worktree self-update --check  # only check, don't install\n```\n\nWhen installed via Composer, use Composer to update:\n\n```bash\ncomposer global update jeffersongoncalves/git-worktree-cli\n```\n\n## How the merge check works\n\nFor each linked worktree (the main worktree and bare repos are skipped)\nthe tool inspects the branch checked out in that worktree and compares\nit to the main branch:\n\n1. If the worktree is detached or on the main branch itself, it is skipped.\n2. If branch tip equals main tip → **same as main**.\n3. If branch tip is an ancestor of main (direct/fast-forward/merge commit)\n   → **merged**.\n4. Otherwise `git cherry main branch` is used to detect **squash/rebase\n   merges** — if every commit on the branch has an equivalent patch on\n   main, the branch is considered merged.\n5. Anything else is reported as **not merged**.\n\n`ahead/behind` counts come from `git rev-list --left-right --count`\nbetween the branch and the main branch.\n\n## Main branch detection\n\nIn order of priority:\n\n1. `--main=\u003cname\u003e` flag if provided and the ref exists\n2. The remote default branch (`origin/HEAD`)\n3. Conventional names: `main`, `master`, `develop`, `trunk`\n\n## Validation\n\nThe command fails fast when:\n\n- The target path is not a git repository\n- The repository has no linked worktrees (only the main checkout)\n- The main branch cannot be resolved\n\n## Development\n\n```bash\ncomposer install\ncomposer test       # Pest tests + Pint lint\ncomposer lint       # Auto-fix style\ncomposer build      # Build the PHAR into builds/git-worktree\n```\n\nThe PHAR is emitted at `builds/git-worktree`. The `build.yml` workflow\nrebuilds and commits it back to `main` on every push, using the latest\ngit tag as the embedded version.\n\nFresh git repositories used by the test suite are created under\n`tests/tmp/` (which is gitignored).\n\n## Release\n\n1. Merge changes to `main` — CI builds a fresh `builds/git-worktree`\n   against the latest tag and commits it back.\n2. Create a new GitHub release (tag `vX.Y.Z`).\n3. The `publish-phar.yml` workflow attaches `git-worktree.phar` to the\n   release and `update-changelog.yml` updates `CHANGELOG.md` + `version.txt`.\n\nThe `self-update` command pulls the PHAR asset from the latest release.\n","funding_links":["https://github.com/sponsors/jeffersongoncalves"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeffersongoncalves%2Fgit-worktree-cli","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeffersongoncalves%2Fgit-worktree-cli","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeffersongoncalves%2Fgit-worktree-cli/lists"}