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

gitcurl

v1.0.0

Published

Clone git repositories without .git and optionally pick paths

Readme

gitcurl

gitcurl 是对 git clone 的轻量包装:克隆完成后自动删除 .git 目录,适合拉取模板、脚手架或只需源码、不需要 Git 历史的场景。支持从仓库中提取指定文件或目录到本地任意路径。

环境要求

  • Node.js >= 16.7.0
  • Git 已安装并在 PATH 中可用

若未检测到 Git,会提示安装方式:

macOS:   brew install git
Windows: https://git-scm.com/download/win
Linux:   apt install git / yum install git

安装

# 全局安装(推荐)
npm install -g gitcurl

# 临时使用
npx gitcurl <repository>

# 本地开发
git clone <this-repo>
cd gitcurl
npm link

快速开始

# 克隆仓库,自动删除 .git
gitcurl https://github.com/user/repo.git

# 指定本地目录名
gitcurl https://github.com/user/repo.git my-project

# 指定分支
gitcurl https://github.com/user/repo.git my-project -b main

# 需要完整历史时
gitcurl https://github.com/user/repo.git --full

用法

gitcurl <repository> [<directory>] [git clone 选项...]
gitcurl <repository> [<directory>] -p <仓库内路径> -o <本地路径> [git clone 选项...]

| 参数 | 说明 | | --- | --- | | <repository> | 仓库地址,支持 HTTPS、SSH 等 git clone 支持的格式 | | <directory> | 可选,克隆到本地的目录名,省略时使用仓库名 | | -p <path> | 仓库内的文件或目录路径(相对仓库根目录) | | -o <path> | 本地目标路径,不存在时自动创建 | | --full | 克隆完整历史(默认仅拉取最近一次提交) | | -h, --help | 显示帮助 | | -V, --version | 显示版本号 |

功能说明

1. 包装 git clone

gitcurl 底层调用 git clone,完整透传所有 git clone 参数、行为和环境变量(如 GIT_SSH_COMMANDhttp.proxy 等),用法与原生 git clone 一致,只是不需要手动输入 clone 子命令。

gitcurl [email protected]:user/repo.git
gitcurl https://github.com/user/repo.git -b develop --single-branch
gitcurl https://github.com/user/repo.git --recurse-submodules

2. 浅克隆(默认)

为加快大仓库的拉取速度,默认使用 --depth 1 浅克隆,只获取最新一次提交,不拉取完整历史。

# 默认浅克隆
gitcurl https://github.com/user/large-repo.git

# 需要完整历史
gitcurl https://github.com/user/large-repo.git --full

# 自定义深度(会覆盖默认值)
gitcurl https://github.com/user/large-repo.git --depth 5

3. 自动删除 .git

克隆成功后,默认删除目标目录下的 .git 文件夹,只保留工作区文件。

以下情况不会删除 .git

  • 使用了 --bare--mirror 选项

4. 提取指定路径(-p / -o)

在克隆并删除 .git 之后,可将仓库内指定文件或目录复制到本地任意路径。-p-o 必须成对使用。

# 提取单个文件
gitcurl https://github.com/user/repo.git -p README.md -o ./docs/readme.md

# 提取目录
gitcurl https://github.com/user/repo.git -p packages/core -o ./core

# 结合 clone 选项
gitcurl https://github.com/user/repo.git mydir -b main -p src/utils -o ./utils

说明:

  • -p 路径相对于克隆后的仓库根目录
  • -o 目标路径的父目录不存在时会自动创建
  • 支持文件和目录,跨平台(macOS / Windows / Linux)
  • 复制完成后会自动删除克隆目录,可重复执行而不会因目录已存在而失败

示例

拉取项目模板

gitcurl https://github.com/user/vite-template.git my-app
cd my-app
npm install

只拿某个子目录

gitcurl https://github.com/user/monorepo.git -p apps/web -o ./web

私有仓库(SSH)

gitcurl [email protected]:org/private-repo.git

私有仓库(HTTPS + Token)

gitcurl https://<token>@github.com/org/private-repo.git

注意事项

  • -p / -ogitcurl 专用参数,会在调用 git 前被剥离,不会传给 git clone
  • --fullgitcurl 专用参数,用于关闭默认浅克隆
  • gitcurl-o 表示本地输出路径;若需设置 remote 名称,请使用 git 的 --origin 选项
  • -p 指定的路径在仓库中不存在,命令会以非零状态码退出并提示错误

与 git clone 对比

| | git clone | gitcurl | | --- | --- | --- | | 保留 .git | 是 | 否(默认删除) | | 提取子路径 | 需手动操作 | 支持 -p / -o | | 命令形式 | git clone <url> | gitcurl <url> |

跨平台支持

支持 macOSLinuxWindows 三大平台,依赖均为 Node.js 内置模块,无第三方依赖。

| 能力 | macOS | Linux | Windows | | --- | --- | --- | --- | | 全局安装 (npm install -g) | ✅ | ✅ | ✅ | | 浅克隆 / 删 .git | ✅ | ✅ | ✅ | | -p / -o 路径复制 | ✅ | ✅ | ✅ | | 路径分隔符 /\ | ✅ | ✅ | ✅ |

前提条件:

  • 已安装 Node.js >= 16.7.0
  • 已安装 Git 并加入 PATH(Windows 需安装 Git for Windows

开发

npm test

License

MIT