Skip to content

Installation

Install with Homebrew

sh
brew tap arcadia-eng/cleft https://github.com/arcadia-eng/cleft
brew install cleft

If Homebrew requires tap trust, run brew trust --formula arcadia-eng/cleft/cleft before retrying.

Install with Nix

With flakes enabled, run:

sh
nix profile install github:arcadia-eng/cleft

Download a release binary

Download the archive for your operating system and CPU and its SHA256SUMS from Cleft releases. Verify the matching checksum before unpacking. For example, on x86_64 Linux:

sh
archive=filename-from-release.tar.gz
awk -v file="$archive" '$NF == file' SHA256SUMS | sha256sum -c - &&
  tar -xzf "$archive" &&
  mkdir -p "$HOME/.local/bin" &&
  install -m 0755 cleft "$HOME/.local/bin/cleft" &&
  ln -sf cleft "$HOME/.local/bin/git-cleft"

Set archive to the filename you downloaded. Use shasum -a 256 -c - if sha256sum is unavailable.

Build from source

Install Git, Make and a C17 compiler. The default build links only system libraries.

sh
git clone https://github.com/arcadia-eng/cleft.git
cd cleft
make && sudo make install

For a user-local install, run make install PREFIX="$HOME/.local" instead. Set DESTDIR to stage the install under a different root.

Choose build options

  • Set ARCH_FLAGS="-march=armv8-a+crypto" on ARM64 Linux or ARCH_FLAGS="-msha -mssse3" on x86-64 if your CPU supports those instructions. Apple Silicon Clang enables hardware SHA by default.
  • Run make CLEFT_USE_SYS_ZLIB=1 to link system zlib instead of the built-in decoder.
  • Run make asan for a build with AddressSanitizer and UndefinedBehaviorSanitizer.
  • Run make test with Python and Git to exercise the source build.

Create a worktree

If you installed into a user directory, put its bin directory on PATH. Check both entry points with cleft --version and git cleft --version. From an existing Git working tree, run:

sh
cleft add -b feature/work ../wt-feature
cleft list

CLI reference

Command syntax

text
cleft [-C <path>] add [<options>] <path> [<commit-ish>]
cleft [-C <path>] include [--json] <worktree-path>
cleft [-C <path>] doctor [--json]
cleft [-C <path>] <list|lock|unlock|move|remove|repair|prune> [<args>]

Choose a repository

-C <path> or -C<path> changes the starting directory. Put it before the subcommand. Repeat it to resolve each subsequent relative directory from the preceding one. With git cleft, you can also use Git's git -C <path> cleft add <worktree-path> syntax.

Create a worktree

sh
cleft add -b feature/parser ../wt-parser HEAD
cleft add -qd ../wt-test HEAD~1
cleft add --require-cow --verify=hash --detach ../wt-verified HEAD

Use -b <branch> for a new branch, -B <branch> to create or reset one, and -d or --detach for a detached checkout. Combine compatible short options, for example -qd or -qb <branch>. Use -- to end options. Other Git options are supported directly or delegated to Git as needed.

Control cloning and verification

Option Effect
--require-cow
Fail instead of falling back to plain git worktree add when CoW cannot be used. This does not require every file to originate from a reflink.
--verify=stat
Default. Use index stat metadata and a timestamp guard to verify donor files.
--verify=hash
Read and hash donor file contents for verification.
--include / --no-include
Override whether include manifests apply.
--index-version=2\|3\|4
Override the index version on the native path.
--json
Report the result as JSON. Check the exit status and, when provided, the backend and fallback_reason fields.

Manage worktrees

  • cleft include <worktree-path> applies an include manifest from the current source worktree to an existing one. Add --json for a machine-readable result.
  • cleft doctor --json reports local filesystem capabilities and relevant repository settings. Omit --json for readable text.
  • cleft list, lock, unlock, move, remove, repair and prune run the corresponding git worktree command with the supplied arguments.

Configuration

  • git config cleft.autoInclude false disables automatic manifest application for this repository. Use --global to set a user-wide default. --include and --no-include take precedence for one invocation.
  • git config index.version 2 selects an older index format if another tool needs it. Cleft uses v4 unless configured otherwise or overridden with --index-version.
  • Cleft reads relevant Git settings, including the repository object format, sparse checkout and worktree configuration. Depending on the settings, it may ask Git to register the worktree or check out affected paths.

Ignored files

Include ignored paths

A manifest in the source worktree root lists local files or directories to bring into new worktrees, such as dependency caches. Use one pattern per line:

gitignore
/node_modules/
/.cache/**/*.bin
!/.cache/private/

Patterns match relative to the source root and support recursive globs (**) and negations (!). Lines starting with # are comments. .cleftinclude takes precedence over .worktreeinclude when both are present. Only matching Git-ignored paths are eligible. Tracked files and .git metadata are not copied by the manifest, and paths that would escape through traversal or symlinks are rejected.

Skip inclusion

Manifest application is enabled by default. Review manifests from unfamiliar repositories, and do not list credentials or other sensitive files. When Cleft delegates the whole operation to plain Git, do not rely on include files being copied.

Use --no-include for one worktree, or set git config cleft.autoInclude false in the source repository. Use --include to override that setting for one worktree.

Platform support

Choose a volume

Reflinks share file data until a write. Changing a file in the new worktree does not change the source file. Git metadata is still shared, as it is with any linked worktree.

macOS with APFS

On APFS, Cleft uses clonefileat to clone clean files. It can clone whole clean subtrees and use Git objects for the files that differ.

Linux with XFS or Btrfs

On XFS formatted with reflink=1 and on Btrfs, Cleft uses the FICLONE ioctl. It creates directories and clones files in parallel. Put the source and destination on the same writable reflink-capable volume.

When cloning is unavailable

On filesystems without compatible copy-on-write cloning, such as ext4, tmpfs or NFS, Cleft delegates to git worktree add. Across volumes, Git creates the worktree without cloning. Use --require-cow to fail instead of allowing Git to create the worktree.

Windows is not supported.

Coding agent setup

Tell coding agents to use cleft add in the repository's AGENTS.md. Use cleft remove or git worktree remove rather than deleting the directory by hand.

Troubleshooting

Symptom What to check
git cleft is not found
Put the install directory on PATH and check that it contains the git-cleft entry point as well as cleft.
add is slower than expected
Read cleft doctor --json for cow_supported and detail, and inspect backend or fallback_reason from cleft add --json.
doctor reports CoW but add delegates
Doctor probes the source volume, not the requested destination. Confirm both paths are on the same volume and check for partial clones or unsupported modes.
Ignored files did not appear
Check cleft.autoInclude, the active manifest, Git ignore rules and the selected backend.
Git refuses to remove a worktree
Check git worktree list and inspect the target for changes. Preserve any needed files before removing it.

Include the Cleft and Git versions and relevant doctor output in a bug report. Remove any private paths before sharing it.

Architecture

  1. Read the target tree and indexes from eligible donor worktrees. Reuse blobs only when donor files match the expected Git blob and mode.
  2. On the stat path, require both change and modification timestamps to predate the donor index timestamp and check file metadata before and after cloning. The hash path verifies file contents instead.
  3. Reflink eligible files with APFS clonefileat or Linux FICLONE. Materialize files without suitable donors from Git objects. Hand checkout filters and conversions to Git for the affected paths.
  4. Reserve a unique worktree admin directory and write its registration files atomically on the native registration path. This avoids Git's concurrent commondir race there. Write the binary index with a TREE cache-tree, normally in v4 format.

Promisor clones and other unsupported cases delegate to Git instead of assuming that all objects are available locally.

Benchmarks

On APFS with vercel/next.js, median creation time at HEAD was 0.8541 s with Cleft and 4.4519 s with Git. Median disk allocation was 16.88 MiB with Cleft and 299.50 MiB with Git on a dedicated APFS volume.

For an older revision at HEAD~200, the creation medians were 0.8781 s with Cleft and 3.4564 s with Git. With 8 worktrees created concurrently at HEAD, the batch medians were 5.685 s and 16.611 s, respectively.

See the full results for the other tools, first status timings, index sizes and measurement conditions.