Download the PHP package jeffersongoncalves/git-worktree-cli without Composer
On this page you can find all versions of the php package jeffersongoncalves/git-worktree-cli. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jeffersongoncalves/git-worktree-cli
More information about jeffersongoncalves/git-worktree-cli
Files in jeffersongoncalves/git-worktree-cli
Package git-worktree-cli
Short Description CLI tool to audit git worktrees and check whether their branches have been merged into the main branch.
License MIT
Homepage https://github.com/jeffersongoncalves/git-worktree-cli
Informations about the package git-worktree-cli
git-worktree-cli
CLI tool to audit git worktrees in a repository and report whether each
worktree's branch has already been merged into the main branch. Includes
a clean command to remove merged worktrees and keep the workspace tidy.
Built with Laravel Zero and modeled on the other CLIs in this monorepo.
Requirements
- PHP
^8.2 gitavailable onPATH- A git repository with at least one linked worktree
Install
Global (recommended)
The binary git-worktree will be on your PATH as long as Composer's
global vendor/bin is in it.
From source
Usage
Add a worktree
Resolution order: existing local branch → existing remote branch (creates a
tracking branch) → new branch from --from or the auto-detected main.
Clean merged worktrees
Protected branches
Some branches stay merged but should never be cleaned (long-lived develop,
staging, release/*, …). The main branch is always skipped automatically;
protection is for the extra branches you want to keep.
Two ways to protect, combined as a union on every clean run:
- Per-run flag —
--protect=<branch-or-glob>(repeatable). - Per-repo config file — persistent, managed with
config:*commands.
The config lives at ~/.config/git-worktree/<owner>-<repo>.json
(honoring XDG_CONFIG_HOME; the slug is derived from the origin remote,
falling back to the directory name plus a short hash when there is no remote):
--no-config ignores the file for a single run; config:disable (or
"enabled": false) turns it off persistently. Either way, --protect flags
still apply.
List worktrees
Keep the CLI up to date
When installed from the released PHAR, self-update from the terminal:
When installed via Composer, use Composer to update:
How the merge check works
For each linked worktree (the main worktree and bare repos are skipped) the tool inspects the branch checked out in that worktree and compares it to the main branch:
- If the worktree is detached or on the main branch itself, it is skipped.
- If branch tip equals main tip → same as main.
- If branch tip is an ancestor of main (direct/fast-forward/merge commit) → merged.
- Otherwise
git cherry main branchis used to detect squash/rebase merges — if every commit on the branch has an equivalent patch on main, the branch is considered merged. - Anything else is reported as not merged.
ahead/behind counts come from git rev-list --left-right --count
between the branch and the main branch.
Main branch detection
In order of priority:
--main=<name>flag if provided and the ref exists- The remote default branch (
origin/HEAD) - Conventional names:
main,master,develop,trunk
Validation
The command fails fast when:
- The target path is not a git repository
- The repository has no linked worktrees (only the main checkout)
- The main branch cannot be resolved
Development
The PHAR is emitted at builds/git-worktree. The build.yml workflow
rebuilds and commits it back to main on every push, using the latest
git tag as the embedded version.
Fresh git repositories used by the test suite are created under
tests/tmp/ (which is gitignored).
Release
- Merge changes to
main— CI builds a freshbuilds/git-worktreeagainst the latest tag and commits it back. - Create a new GitHub release (tag
X.Y.Z, novprefix). - The
publish-phar.ymlworkflow attachesgit-worktree.pharto the release andupdate-changelog.ymlupdatesCHANGELOG.md+version.txt.
The self-update command pulls the PHAR asset from the latest release.