Skip to content

feat: support checking out a git commit - #4

Merged
jvmakine merged 2 commits into
block:mainfrom
jvmakine:juho/git-commit
Oct 23, 2026
Merged

jvmakine merged 2 commits into
block:mainfrom
jvmakine:juho/git-commit

Conversation

@jvmakine

@jvmakine jvmakine commented Oct 23, 2026 •

Copy link
Copy Markdown
Collaborator

Git sources can choose a branch or tag with ref=, but they can't be pinned to an exact commit. ref= goes through git clone --branch, which doesn't accept a commit hash.

This adds a commit=<hash> query parameter, passed to git clone --revision:

git+https://github.com/org/repo?commit=9f3c1e…&depth=1

Git fetches only the history leading to the commit and checks it out detached:

  • depth limits that history as usual. With depth=1, only the one commit is transferred, however old it is.
  • Git itself rejects the bad cases: commit combined with ref, and short or unknown hashes ("Remote revision … not found").
  • The value is passed as its own argument, so it can't be read as a git option.

The clone needs git 2.49 or later. The server must also allow fetching a commit by hash, which every server speaking git protocol v2 (the default since git 2.26) does, including GitHub.

I want this so scaffolder can re-render the exact template revision a directory was scaffolded from.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@jvmakine
jvmakine marked this pull request as ready for review October 23, 2026 04:01
@jvmakine
jvmakine requested a review from alecthomas as a code owner October 23, 2026 04:01
alecthomas
alecthomas previously approved these changes Oct 23, 2026
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@jvmakine
jvmakine merged commit 587bf9e into block:main Oct 23, 2026
6 checks passed
@jvmakine
jvmakine deleted the juho/git-commit branch October 23, 2026 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants