npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

git-pull-dir

v0.3.3

Published

A CLI tool to clone a specific directory from a remote git repository to local, designed for syncing skills managed by internal GitLab into projects.

Readme

git-pull-dir

从远程 Git 仓库中仅拉取指定目录或文件到本地 — 告别巨量 monorepo 的完整克隆。

npm version License

Motivation

大型 monorepo(如 facebook/react-nativevercel/next.js)体积巨大,但开发者往往只关心其中某个子目录(如 packages/core)。传统 git clone 会下载整个仓库历史,浪费带宽和时间。

git-pull-dir 利用 Git 的 sparse-checkout + partial clone 技术,让你只拉取需要的部分。

Requirements

  • Node.js ≥ 18.0.0 (LTS)
  • Git ≥ 2.25.0(sparse-checkout 命令在该版本引入)

Installation

# 全局安装
npm install -g git-pull-dir

# 或使用 npx 免安装运行
npx git-pull-dir <url> <dir>

Usage

git-pull-dir <git-url> <git-dir> [local-dir] [--branch=<name>] [--quiet]

| 参数 | 是否必填 | 描述 | 示例 | |------|----------|------|------| | <git-url> | 是 | 远程 Git 仓库 URL(HTTPS / SSH) | https://github.com/facebook/react-native.git | | <git-dir> | 是 | 仓库内需要拉取的目录或文件路径 | packages/core | | [local-dir] | 否 | 本地存放目录。省略时取 <git-dir> 最后一段作为目录名 | ./my-core | | --branch=<name> | 否 | 指定分支,默认 main | --branch=main | | --quiet | 否 | 静默模式,仅显示 spinner | --quiet |

包名以 git- 为前缀,Git 别名机制使 git pull-dir 也可直接调用。

Examples

# 基本用法:拉取 react-native 的 packages/core 到 ./core
git-pull-dir https://github.com/facebook/react-native.git packages/core

# 指定本地目录名
git-pull-dir https://github.com/facebook/react-native.git packages/core ./my-core

# 通过 git 子命令调用
git pull-dir https://github.com/vercel/next.js.git packages/next ./next-local

# SSH 地址
git-pull-dir [email protected]:facebook/react-native.git packages/core

# 指定分支
git-pull-dir https://github.com/facebook/react-native.git packages/core --branch=main

# 静默模式
git-pull-dir --quiet https://github.com/facebook/react-native.git packages/core ./my-core

Output

# 默认模式:逐行显示步骤
$ git-pull-dir https://github.com/facebook/react-native.git packages/core ./my-core
clone in...
setting sparse-checkout...
checkout...
save at /Users/me/my-core

# --quiet 模式:仅显示 spinner
$ git-pull-dir --quiet https://github.com/facebook/react-native.git packages/core ./my-core
⠋ downloading...
save at /Users/me/my-core

# 目录已存在,用户确认覆盖
$ git-pull-dir https://github.com/facebook/react-native.git packages/core ./my-core
目录 /Users/me/my-core 已存在,是否覆盖?(yes/no)
yes
clone in...
setting sparse-checkout...
checkout...
save at /Users/me/my-core

# 用户取消
$ git-pull-dir https://github.com/facebook/react-native.git packages/core ./my-core
目录 /Users/me/my-core 已存在,是否覆盖?(yes/no)
no
cancelled

How It Works

采用 partial clone + sparse-checkout 组合方案:

git clone --filter=blob:none --no-checkout <url> <work-dir>
git -C <work-dir> sparse-checkout init --cone
git -C <work-dir> sparse-checkout set <git-dir>
git -C <work-dir> checkout <branch>
  1. --filter=blob:none — 初始克隆时不下载文件内容(blob),只下载 commit 树结构
  2. --no-checkout — 克隆后不立即检出工作区文件
  3. sparse-checkout init --cone — 启用锥形模式,仅允许显式声明的目录被检出
  4. sparse-checkout set <dir> — 声明需要检出的目录

这样只有指定目录的文件会实际传输,不会下载整个仓库历史。

Exit Codes

| 退出码 | 含义 | |--------|------| | 0 | 成功 / 用户取消 | | 1 | 参数错误 / Git 未安装或版本过低 / URL 不可达 / 目录不存在 / 网络超时 / 磁盘空间不足 | | 130 | 用户按 Ctrl+C 中断 |

License

MIT