Skip to content

A lightweight CLI to fetch individual files from remote Git repositories and track them locally for reproducibility.

License

arkahna/git-file-fetch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

git-file-fetch

CI npm version license: MIT node >= 22

A lightweight CLI to fetch individual files from remote Git repositories and track them locally for reproducibility.

⚠️ NOT YET PUBLISHED TO NPM This package is pending its initial npm release. Until then, use the local testing methods below to try it out.

🧪 Local Testing (Pre-Release)

The package is not yet available on npm. Here's how to test it locally:

Option 1: Link Globally (Recommended)

Test the tool as if it were installed from npm:

# Clone and setup
git clone https://github.com/arkahna/git-file-fetch.git
cd git-file-fetch
pnpm install
pnpm build
npm link

# Now use from anywhere on your system
git-file-fetch "https://github.com/octokit/core.js.git@main:LICENSE"

# To unlink later
npm unlink -g @arkahna-npm/git-file-fetch

Option 2: Direct Execution

Quick testing during development:

# Clone and setup
git clone https://github.com/arkahna/git-file-fetch.git
cd git-file-fetch
pnpm install
pnpm build

# Using built version
node dist/index.js "https://github.com/octokit/core.js.git@main:LICENSE" --dry-run

# Or run TypeScript directly (no build needed)
pnpm start "https://github.com/octokit/core.js.git@main:LICENSE" --dry-run

Option 3: Test in Another Project

Most realistic test of the published package:

# In git-file-fetch directory
pnpm install
pnpm pack
# Creates: arkahna-npm-git-file-fetch-0.1.0.tgz

# In your test project
npm install /path/to/git-file-fetch/arkahna-npm-git-file-fetch-0.1.0.tgz
npx git-file-fetch "https://github.com/user/repo.git@main:file.ts"

Quick Start (After npm Release)

🚀 Just want to use it?

npx @arkahna-npm/git-file-fetch "https://github.com/user/repo.git@main:path/to/file.ts"

📦 Want to install it?

npm install -D @arkahna-npm/git-file-fetch
npx @arkahna-npm/git-file-fetch "https://github.com/user/repo.git@main:path/to/file.ts"

🔧 Want to contribute/develop?

git clone https://github.com/arkahna/git-file-fetch.git
cd git-file-fetch
pnpm install
pnpm build

Available development commands:

  • pnpm build - Build the project
  • pnpm typecheck - Run TypeScript type checking
  • pnpm lint:check - Run ESLint checks
  • pnpm lint:fix - Run ESLint with auto-fix
  • pnpm lint:md - Run Markdown lint checks
  • pnpm lint:md:fix - Run Markdown lint with auto-fix
  • pnpm test:smoke - Run smoke test

What it does

  • Shallow Fetch: Performs a shallow fetch of the target ref without a full clone
  • File Extraction: Reads the file at that specific commit using git show
  • Local Copy: Copies the requested file(s) into your current working directory
  • Manifest Update: Writes an entry for each fetched file to a manifest for tracking provenance

Documentation

Requirements

  • Git available on your PATH
  • Node.js >= 22 (supports 22, 23, 24)

License

MIT © Arkahna

Originally contributed by Aneki

                  _    _
  __ _ _ __   ___| | _(_)
 / _` | '_ \ / _ \ |/ / |
| (_| | | | |  __/   <| |
 \__,_|_| |_|\___|_|\_\_|

  === ᚢ · ᚦ · ᚲ ===

About

A lightweight CLI to fetch individual files from remote Git repositories and track them locally for reproducibility.

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published