Skip to content

git worktree-merge

Merge branches across worktrees

TIP

This command is also available as daft merge. See daft merge.

Description

Merges one or more source branches into a target worktree's branch.

When --into is omitted, the target is the current worktree's branch, mirroring git merge. When --into <target> is supplied, the merge is performed against that worktree's branch from wherever you are.

Multiple sources invoke git's octopus strategy, announced explicitly.

Finish commands (--abort, --continue, --quit) take an optional positional <worktree|branch>; default to the current worktree's branch.

When post-merge cleanup deletes a merged branch's remote ref (enabled via daft.branchDelete.remote), that delete pushes no content, so the repo's pre-push hook is skipped by default. Set daft.pushVerify to always for hooks that gate deletes by ref name; merge has no per-invocation bypass.

Usage

git worktree-merge [OPTIONS] [SOURCE_OR_TARGET]

Arguments

ArgumentDescriptionRequired
<SOURCE_OR_TARGET>Source branches/commits to merge (start mode), OR optional target worktree/branch for --abort / --continue / --quit (finish mode; max one positional)No

Options

OptionDescriptionDefault
--into <TARGET>Target worktree/branch. Defaults to the current worktree's branch
--abortAbort an in-progress merge in the named worktree (defaults to CWD)
--continueContinue an in-progress merge in the named worktree (defaults to CWD)
--quitQuit an in-progress merge without resetting the index (defaults to CWD)
-m <MSG>Commit message for the merge commit (mirrors git merge -m)
-F, --file <FILE>Read the commit message from FILE (mirrors git merge -F)
--editLaunch the editor to edit the merge commit message
--no-editAccept the auto-generated merge commit message without editing
--cleanup <MODE>Message cleanup mode (mirrors git merge --cleanup)
--mergeExplicit merge style — always create a merge commit. This is the default; the flag exists for canceling a config-set default style
--squashSquash style — collapse source's commits into one squashed commit on target
--rebaseRebase style — rebase source onto target, then fast-forward (linear, preserves commits)
--rebase-mergeRebase-merge style — rebase source onto target, then create a merge commit
--commitAutomatically create the merge commit after a successful merge
--no-commitLeave the merge staged without committing
--signoffAdd a Signed-off-by trailer to the merge commit
--no-signoffExplicitly disable signoff (cancel a config default)
-s, --strategy <STRAT>Merge strategy to use (e.g. ours, recursive, octopus)
-X, --strategy-option <OPT>Strategy-specific option (repeatable; mirrors git merge -X)
-S, --gpg-sign <KEYID>GPG-sign the merge commit. Accepts an optional KEYID; omit to use the default key
--no-gpg-signDo not GPG-sign the merge commit (cancels commit.gpgsign config)
--verify-signaturesVerify that the tip commit of the source is signed with a valid key
--no-verify-signaturesDo not verify signatures on the source tip commit
--allow-unrelated-historiesAllow merging histories that share no common ancestor
--statShow a diffstat at the end of the merge
-n, --no-statSuppress the diffstat at the end of the merge
--adopt-targetWhen the target has no worktree and the merge is not a pure fast-forward, create an ephemeral worktree to perform the merge without prompting
--no-adopt-targetWhen the target has no worktree and the merge is not a pure fast-forward, refuse without prompting
-y, --yesAuto-accept interactive prompts. Implies --adopt-target when neither --adopt-target nor --no-adopt-target is supplied. Future-proofs any new prompts we add
-r, --remove-branchRemove the source worktree and delete the source branch. The local/remote behavior follows branch.deleteRemote (defaults to local-only)
--keep-branchExplicit keep — for canceling a config-set merge.cleanup = remove-branch
--ff-onlyRequire the merge to be fast-forward-equivalent: the source must already contain the target's tip. Supplies merge: ff: only when daft.yml lacks it; matches it when committed
--no-ff-onlyAllow a non-fast-forward merge for this invocation, overriding a committed merge: ff: only policy (announced when it does)
--source-worktree <STATE>Required state of the source branch's worktree: clean refuses a missing or dirty source worktree (supplies merge: source_worktree: clean); any relaxes a committed clean for this invocation
--skip-hooks <SELECTOR>Skip hooks this run (all<hook>
--hooks <MODE>How this run's hook jobs executeauto
--skip-tag <TAG>Skip hook jobs carrying TAG, plus their dependents (repeatable). Sugar for --skip-hooks tag:<TAG> — e.g. --skip-tag deep for a fast gate pass
--only-tag <TAG>Run only hook jobs carrying TAG (repeatable)
--set-defaultWrite the resolved style/cleanup choices to git config --local after the merge succeeds
-v, --verboseBe verbose; show detailed progress
--format <FORMAT>Output format. Mutually exclusive with --template
--template <STR>Tera template string. Mutually exclusive with --format
--no-headersOmit header row (tsv/csv only)

Global Options

OptionDescription
-h, --helpPrint help information
-V, --versionPrint version information

See Also

Released under MIT or Apache-2.0.