RH

rich-harris/degit

开发工具

本页由 AI 翻译,技术细节请以原文为准。 查看原文

7956 stars 质量 73 趋势 44MIT

简单的项目支架

概览

复制git仓库。当你运行degit some-user/some-repo时,它会找到https://github.com/some-user/some-repo上的最新提交,并下载相应的tar文件到平台合适的缓存目录(如果本地还没有的话)。在Linux/BSD上,设置时会XDG_CACHE_HOME,否则使用~/.cache/degit;macOS上使用~/Library/Caches/degit;在Windows上使用%LOCALAPPDATA%\degit。(这比用git克隆快得多,因为你不会下载完整的git历史。)degit通过内部git后端解析refs,默认下载tar快照,当tarball抓取或解压失败时会退回到SSH克隆。公共HTTPS源不需要在你的PATH上放置本地git二进制文件,但SSH/私有仓库仍然需要。 - Node.js 或更高版本(参见 package.json 中的引擎)- 开发该仓库时使用 Bun(详见包中的 packageManager。

概述(AI 翻译)

degit 会复制 git 仓库。当你运行 degit some-user/some-repo 时,它会找到 https://github.com/some-user/some-repo 上的最新提交,并下载相关 tar 文件到平台合适的缓存目录(如果本地还没有的话)。(这比用 git clone 快得多,因为你不需要下载完整的 git 历史。)

degit 通过内部 git 后端解析引用,默认下载 tar 快照,当 tarball 获取或解压失败时会退回 SSH 克隆。公共 HTTPS 源不需要在你的 PATH 上设置本地 git 二进制文件,但 SSH/私有仓库仍然需要。

要求

  • Node.js 20 或更高版本(参见 [engines,见 package.json)

安装

快速开始

将GitHub仓库的默认分支下载到当前目录:

下载到新文件夹:

只下载特定文件:

使用特定的标签、分支或提交:

关于完整的CLI参考、ESM API和degit.json操作,请参见docs/USAGE.md。

为什么不直接git clone --depth 1?

  • 模板中没有剩余的.git文件夹。
  • 缓存 tar 归档以供离线重用。

本页由 AI 翻译,技术细节请以原文为准。

README

以下为原文 README 节选,完整内容请查看原文。

degit — straightforward project scaffolding

degit makes copies of git repositories. When you run degit some-user/some-repo, it finds the latest commit on https://github.com/some-user/some-repo and downloads the associated tar file to the platform-appropriate cache directory if it doesn’t already exist locally. (This is much quicker than using git clone, because you’re not downloading the entire git history.)

degit resolves refs through an internal git backend, downloads tar snapshots by default, and falls back to SSH cloning when tarball fetches or extraction fail. Public HTTPS sources do not need a local git binary on your PATH, but SSH/private repositories still do.

Requirements

  • Node.js 20 or later (see engines in package.json)

Installation

npm install -g degit

Quick start

Download the default branch of a GitHub repo to the current directory:

degit user/repo

Download to a new folder:

degit user/repo my-new-project
degit -r user/repo

Download only specific files:

degit user/repo my-project --files README.md,src/index.ts

Use a specific tag, branch, or commit:

degit user/repo#v1.0.0

For the full CLI reference, ESM API, and degit.json actions, see docs/USAGE.md.

Why not just git clone --depth 1?

  • No leftover .git folder from the template.
  • Caches tar archives for offline reuse.
  • Less to type (degit user/repo versus git clone --depth 1 ...).
  • Composable post-clone actions via degit.json.
  • Built-in support for subdirectories, file filtering, and aliases.

Agent skill

Install the reusable degit skill for agents that support SKILL.md files:

# project-level install
npx skills add Rich-Harris/degit --skill degit

# global install
npx skills add Rich-Harris/degit --skill degit -g

Then ask the agent to download a repository or template. The skill helps it choose a source, ref, and destination; handle private repositories and aliases; and avoid overwriting a non-empty destination without confirmation.

See skills/degit/SKILL.md for the full skill instructions.

Documentation

在 GitHub 查看完整 README

推荐工具

换一个关键词,或者移除筛选条件。

安装

npx skillfish add rich-harris/degit
新手?先看 mcpskill.org 教程 →