Skip to content

Git Utils

Terminal window
pnpm add @theholocron/git-utils

Node-only: it shells out to git and touches the filesystem. Zero dependencies.

import { parseGitRemoteUrl, upsertManagedBlock } from "@theholocron/git-utils";
parseGitRemoteUrl("git@github.com:theholocron/holocron.git");
// { host: "github.com", owner: "theholocron", repo: "holocron", slug: "theholocron/holocron" }
upsertManagedBlock("node_modules\n", {
start: "# managed: skills",
end: "# end managed: skills",
lines: ["/.agents/"],
});
// "node_modules\n\n# managed: skills\n/.agents/\n# end managed: skills\n"
  • parseGitRemoteUrl and upsertManagedBlock are pure. readGitRemote runs git remote get-url and parses the result with parseGitRemoteUrl; updateGitignore applies upsertManagedBlock to a file.
  • A managed block has no default markers. Choose them and keep them stable, because they are how an existing block is found again.

The full API reference is generated from the package’s TSDoc comments.