git donkey

Updated Jul 13, 2026

Create a linked worktree at ../{repo}.worktrees/{branch}, branching from main by default, a named base branch, or the branch checked out in the current working directory. The command prefers the origin remote and falls back to the first remote when origin is absent, reuses an existing local or remote branch when present, and prompts to pull --rebase the base branch if it is behind (unless --no-pull is set). If the worktree path already exists or the branch is already checked out elsewhere, the command exits with a ⚔️ conflict message. If the base branch has no remote counterpart, the behind check is skipped.

# Create a new worktree for feature/foo from main

git donkey feature/foo

# Use the current branch as the base for the new worktree

git donkey feature/foo .

# Create from a specific base branch without prompting for pull --rebase

git donkey feature/foo release/1.2 --no-pull

Options:

  • --no-pull skips prompting to pull the base branch if it is behind the remote.

Template Overlays

After creating the worktree, git donkey automatically applies template overlay files if a template directory exists for the repository. Template directories are stored under the platform-specific user data directory for git-donkey:

<user-data-dir>/git-donkey/template/<repo-url-slug>

The slug format is <slugified-text>-<adler32-checksum>, where the checksum provides collision resistance while the slugified text remains human-readable.

Use git donkey-template within a repository to display and create the template directory path:

cd ~/projects/myrepo
git donkey-template
# Template directory: /path/to/user-data/git-donkey/template/myrepo-a1b2c3d4

When a template exists, all files from the template directory are copied into the newly created worktree. If a file already exists in the worktree, a warning is issued, but the file is overwritten. This design allows maintaining per-repository configuration files (such as .editorconfig, .vscode/settings.json, or project-specific configurations) and automatically applying them to all new worktrees.

Example template structure:

<user-data-dir>/git-donkey/template/
  myrepo-a1b2c3d4/
    .editorconfig
    .vscode/
      settings.json
    config/
      local.json

On other platforms, the template directory follows the platform's conventions for user data storage (e.g., ~/.local/share/git-donkey/template on Linux or ~/Library/Application Support/git-donkey/template on macOS).