degit — straightforward project scaffolding
degit makes copies of git repositories. When you run
degit some-user/some-repo, it will find the latest commit on https://github.com/some-user/some-repo and download the associated tar file to
~/.degit/some-user/some-repo/commithash.tar.gz if it doesn't already exist locally. (This is much quicker than using
git clone, because you're not downloading the entire git history.)
Requires Node 8 or above, because
await are the cat's pyjamas
npm install -g degit
The simplest use of degit is to download the master branch of a repo from GitHub to the current working directory:
degit user/repo# these commands are equivalentdegit github:user/repodegit firstname.lastname@example.org:user/repodegit https://github.com/user/repo
Or you can download from GitLab and BitBucket:
# download from GitLabdegit gitlab:user/repodegit email@example.com:user/repodegit https://gitlab.com/user/repo# download from BitBucketdegit bitbucket:user/repodegit firstname.lastname@example.org:user/repodegit https://bitbucket.org/user/repo
Specify a tag, branch or commit
The default branch is
degit user/repo#dev # branchdegit user/repo#v1.2.3 # release tagdegit user/repo#1234abcd # commit hash
Create a new folder for the project
If the second argument is omitted, the repo will be cloned to the current directory.
degit user/repo my-new-project
See all options
- Private repositories
Pull requests are very welcome!
Wait, isn't this just
git clone --depth 1?
A few salient differences:
- If you
git clone, you get a
.gitfolder that pertains to the project template, rather than your project. You can easily forget to re-init the repository, and end up confusing yourself
- Caching and offline support (if you already have a
.tar.gzfile for a specific commit, you don't need to fetch it again).
- Less to type (
degit user/repoinstead of
git clone --depth 1 email@example.com:user/repo)
- Composability via actions
- Future capabilities — interactive mode, friendly onboarding and postinstall scripts
You can also use degit inside a Node script:
const degit = ;const emitter =;emitter;emitter;
You can manipulate repositories after they have been cloned with actions, specified in a
degit.json file that lives at the top level of the working directory. Currently, there are two actions —
remove. Additional actions may be added in future.
This will clone
user/another-repo, preserving the contents of the existing working directory. This allows you to, say, add a new README.md or starter file to a repo that you do not control. The cloned repo can contain its own
Remove a file at the specified path.