MCPcopy
hub / github.com/21st-dev/1code / gitCheckoutFile

Function gitCheckoutFile

src/main/lib/git/security/git-commands.ts:70–80  ·  view source on GitHub ↗
(
	worktreePath: string,
	filePath: string,
)

Source from the content-addressed store, hash-verified

68 * to indicate path mode (not branch mode).
69 */
70export async function gitCheckoutFile(
71 worktreePath: string,
72 filePath: string,
73): Promise<void> {
74 assertRegisteredWorktree(worktreePath);
75 assertValidGitPath(filePath);
76
77 const git = createGit(worktreePath);
78 // `--` is correct here - we want path semantics
79 await withLockRetry(worktreePath, () => git.checkout(["--", filePath]));
80}
81
82/**
83 * Checkout (restore) multiple file paths, discarding local changes.

Callers 1

createStagingRouterFunction · 0.90

Calls 4

assertRegisteredWorktreeFunction · 0.90
assertValidGitPathFunction · 0.90
createGitFunction · 0.90
withLockRetryFunction · 0.90

Tested by

no test coverage detected