MCPcopy Create free account
hub / github.com/Wirasm/kild / push

Function push

engine/src/kild/worktree.ts:111–120  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

109 * (which must never reset a shared tree; use {@link ensureWorktree}). `name` is the
110 * kild worktree name (the branch is derived as `kild/<name>`); `base` is the
111 * start-point ref (default: current HEAD). */
112export async function createWorktree(repo: string, name: string, base?: string): Promise<Worktree> {
113 assertSafeBranch(name);
114 const wtPath = worktreePath(name);
115 const ref = worktreeRef(name);
116 // Best-effort pre-clean of a same-named worktree before the force re-create.
117 // Force is intentional here ("new worktree" is destructive-by-request).
118 await execFile('git', ['-C', repo, 'worktree', 'remove', '--force', wtPath]).catch(() => {});
119 const add = ['-C', repo, 'worktree', 'add', '-B', ref, wtPath, ...(base ? [base] : [])];
120 await execFile('git', add);
121 return { branch: ref, path: wtPath, name };
122}
123

Callers 1

listWorktreesFunction · 0.85

Calls 1

worktreeNameFunction · 0.85

Tested by

no test coverage detected