degit
它能做什么
展示如何使用 degit 将项目模板或代码仓库快照复制到新文件夹,且不包含完整的 git 历史。适用于希望从模板快速开始项目的开发者。
适用场景
- ✓开发者想从 GitHub 或 GitLab 模板开始一个新项目的时候。
- ✓开发者想要一份不含 git 历史的代码仓库副本的时候。
- ✓开发者只想要代码仓库中某些特定文件或文件夹的时候。
技能链接
https://github.com/Rich-Harris/degit/blob/master/skills/degit/SKILL.md复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。
使用方法
最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。
可直接粘贴的消息
适用于 Claude Code、Codex 或 Cursor:在项目文件夹中运行,即可安装该技能。
下载 SKILL.md,放进智能体的技能文件夹。
可以这样问 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
--forceunless the user explicitly wants to overwrite its contents. - Use
--cacheto 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--verboseto diagnose failures.--mode=gitstill 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
gitonPATHand working repository credentials. - For reusable shortcuts, use
degit alias <repo> <name>, thendegit <name>; usedegit lsanddegit unalias <name>to manage aliases. - If a template needs post-download changes, explain that its top-level
degit.jsoncan useclone,search_replace, andremoveactions.search_replaceuses a named environment variable for its replacement value. - A downloaded
degit.jsonruns automatically and is template-controlled. For untrusted templates, prefer--no-actionsto skip actions, or--allow-env <names>to limit which environment variablessearch_replacemay read.
If source, ref, destination, or whether the destination is empty is unknown, ask before giving a potentially destructive command.
常见问题
复制的内容包含 git 历史吗?
不包含。该技能说明 degit 复制的是快照,因此不包含历史记录。
我可以只复制部分文件吗?
可以。该技能说明如何只复制特定的文件或文件夹。
我可以在已有文件的文件夹中使用它吗?
该技能说明目标文件夹必须为空,除非你确实想要覆盖,否则它不会建议强制覆盖。
详情
热度
- GitHub 星标
- 8.0k
- 排名
- #12654
- 许可证
- MIT
- 更新时间
- 2026/10/21
评论
- …