Skip to content

Repository files navigation

git-gimme

npm version types CI license

Preview

(っᵔ◡ᵔ)っ ⭐

Ever wanted to download a single file or single folder from a Github repo?

git gimme unjs/giget/templates
git gimme unjs/giget/README.md

Install

npm install -g git-gimme

Installed globally, git gimme works as a native git subcommand.

What's new

Version Highlights
1.0.2 GitHub CLI auth integration and short CLI flags
1.0.0 Download single files from GitHub without cloning entire repositories
0.2.0 Exported function renamed to gitGimme; giget is now a peer dep

Full history in CHANGELOG.md.

Usage

git gimme <source> [dest] [--ignore='pattern,pattern']

A folder

Lands as ./templates:

git gimme unjs/giget/templates

A single file

Lands as ./README.md:

git gimme unjs/giget/README.md

If the path could be either, git-gimme tries folder first and falls back to file.

A pasted GitHub URL

Both /tree/ and /blob/ links work as they are:

git gimme https://github.com/unjs/giget/tree/main/templates
git gimme https://github.com/unjs/giget/blob/main/README.md

A branch, tag, or commit

git gimme 'unjs/giget/templates#v3.2.0'

Without a #ref, the repository's actual default branch is used.

Somewhere other than the current folder

git gimme unjs/giget/templates ./vendor/templates

Skipping files

git gimme unjs/giget ./giget --ignore='*.md,*.lock'

API

import { gitGimme } from "git-gimme";

const { dir, files } = await gitGimme("unjs/giget/templates", {
  dest: "./vendor/templates",
  ignore: "*.md",
});

console.log(`${files} file(s) in ${dir}`);

gitGimme(input, options?)

Option Type Default Description
dest string repo or path's name Where to write the file or folder.
ignore string Comma-separated globs to skip.

Returns { dir, files }: the resolved output path and how many files landed there.

How it works

Core downloading is done by giget — YAGNI 🧘‍♂️. Their page lists everything else that comes with it: private sources via --auth, GitLab / Bitbucket / Sourcehut, offline cache.

As giget is a peer dependency so if already installed, this package simply enhances the DX.

Development

bun install
bun run test
bun run typecheck
bun run build
bun run format

License

MIT © jayF0x

About

git subcommand: download a single file or folder from a repo without a full clone

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages