# degit — Scaffold Projects from Git Repos Without the History > A lightweight scaffolding tool by Rich Harris that copies the latest snapshot of a git repository without cloning the full history. ## Install Save in your project root: # degit — Scaffold Projects from Git Repos Without the History ## Quick Use ```bash # Install globally npm install -g degit # Scaffold from a GitHub repo degit sveltejs/template my-svelte-app # Use a specific branch degit user/repo#dev my-project # Scaffold a subdirectory degit user/repo/src/templates my-template ``` ## Introduction degit makes copies of git repositories without cloning the full history. Created by Rich Harris (the creator of Svelte), it downloads only the latest files as a tarball, making project scaffolding nearly instant. It is particularly popular in the Svelte ecosystem but works with any GitHub, GitLab, or Bitbucket repository. ## What degit Does - Downloads the latest snapshot of a repository without any git history or .git directory - Supports targeting specific branches, tags, or commit hashes with the `#ref` syntax - Copies subdirectories from within a repository, not just the root - Runs post-clone actions defined in a `degit.json` file (like renaming files) - Caches downloaded tarballs locally so repeated scaffolding is instant ## Architecture Overview degit works by fetching the tarball archive that GitHub, GitLab, and Bitbucket expose for any ref. It does not use git clone, so there is no history transfer and no requirement for git to be installed. The downloaded archive is extracted into the target directory. If the repo has a `degit.json` at its root, degit runs the declared actions (like file cloning or removal) after extraction. ## Self-Hosting & Configuration - Install via npm globally or use npx for one-off usage (`npx degit user/repo`) - No configuration required for basic usage - Supports private repos when authenticated via environment tokens - Add a `degit.json` to your template repo to define post-clone actions - Works with GitHub, GitLab, Bitbucket, and custom git hosts via URL syntax ## Key Features - No git history in the output means a clean starting point for new projects - Faster than git clone because it downloads a compressed tarball instead of the full object database - Local caching avoids redundant downloads when scaffolding the same template repeatedly - Subdirectory support lets you keep multiple templates in a single monorepo - Post-clone actions via `degit.json` can rename package names, remove example files, and more ## Comparison with Similar Tools - **git clone --depth 1** — downloads the latest commit but still creates a .git directory; degit gives you clean files only - **GitHub template repositories** — requires a GitHub account and creates a new repo; degit copies files locally without any remote setup - **create-react-app / create-svelte** — framework-specific scaffolders; degit works with any repository on any platform - **tiged** — a community fork of degit with additional fixes; degit is the original with broader recognition ## FAQ **Q: Does degit require git to be installed?** A: No. It fetches tarballs over HTTPS, so git is not needed on the machine. **Q: Can I use degit with private repositories?** A: Yes. Set a GitHub token via the environment and degit will use it to authenticate the download. **Q: What happens if I run degit in a non-empty directory?** A: By default it will fail to prevent overwriting. Use `--force` to override this check. **Q: Is degit maintained?** A: The original repo has limited recent activity. The community fork tiged is actively maintained and fully compatible. ## Sources - https://github.com/Rich-Harris/degit - https://github.com/tiged/tiged --- Source: https://tokrepo.com/en/workflows/asset-21a04d89 Author: AI Open Source