跳到正文
Skillpedia
通用编程8.0k · #12654

degit

它能做什么

展示如何使用 degit 将项目模板或代码仓库快照复制到新文件夹,且不包含完整的 git 历史。适用于希望从模板快速开始项目的开发者。

适用场景

  • ✓开发者想从 GitHub 或 GitLab 模板开始一个新项目的时候。
  • ✓开发者想要一份不含 git 历史的代码仓库副本的时候。
  • ✓开发者只想要代码仓库中某些特定文件或文件夹的时候。

技能链接

https://github.com/Rich-Harris/degit/blob/master/skills/degit/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/Rich-Harris/degit/blob/master/skills/degit/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“我想从 GitHub 上的一个入门模板开始新项目。请帮我复制它。”

每周 5 个新技能,1 分钟读完。

工作原理

该技能提供把代码仓库快照复制到文件夹的命令,并帮助处理分支和子文件夹。它支持 GitHub、GitLab、Bitbucket、Sourcehut 和 Gist。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Help the user scaffold a project with degit. Use npx degit@latest unless they have installed degit globally.

Start with the smallest command that matches their request:

npx degit@latest user/repo
npx degit@latest user/repo my-project
npx degit@latest user/repo#branch my-project

Sources can be GitHub (user/repo, github:user/repo, or a GitHub URL), GitLab (gitlab:user/repo, a GitLab URL, or gitlab://host/user/repo), Bitbucket (bitbucket:user/repo or URL), Sourcehut (git.sr.ht/user/repo, SSH form, or URL), or Gist (https://gist.github.com/<id>, https://gist.github.com/<user>/<id>, git@gist.github.com:<id>.git, or ssh://git@gist.github.com/<id>). A #ref can name a branch, tag, or commit. A source may include a subdirectory path.

  • The destination defaults to the current directory and must be empty. Do not suggest --force unless the user explicitly wants to overwrite its contents.
  • Use --cache to require a cached copy (no network). Without --cache, degit tries the network first and falls back to the cached copy if the network is unreachable. Use --verbose to diagnose failures. --mode=git still works but is unnecessary; tar snapshots are the default.
  • Use --files <paths> or -F <paths> to clone only specific files or directories; separate multiple paths with commas or repeat the flag.
  • Private repositories are handled automatically, with SSH fallback when needed. SSH/private use requires git on PATH and working repository credentials.
  • For reusable shortcuts, use degit alias <repo> <name>, then degit <name>; use degit ls and degit unalias <name> to manage aliases.
  • If a template needs post-download changes, explain that its top-level degit.json can use clone, search_replace, and remove actions. search_replace uses a named environment variable for its replacement value.
  • A downloaded degit.json runs automatically and is template-controlled. For untrusted templates, prefer --no-actions to skip actions, or --allow-env <names> to limit which environment variables search_replace may read.

If source, ref, destination, or whether the destination is empty is unknown, ask before giving a potentially destructive command.

常见问题

复制的内容包含 git 历史吗?

不包含。该技能说明 degit 复制的是快照,因此不包含历史记录。

我可以只复制部分文件吗?

可以。该技能说明如何只复制特定的文件或文件夹。

我可以在已有文件的文件夹中使用它吗?

该技能说明目标文件夹必须为空,除非你确实想要覆盖,否则它不会建议强制覆盖。

详情

作者的原始描述

Download a repository snapshot or template with degit

repo: Rich-Harris/degit

热度

GitHub 星标
8.0k
排名
#12654
许可证
MIT
更新时间
2026/10/21

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

相似技能