Download and extract a git repository (GitHub, GitLab, Bitbucket) from node.
$ npm install download-git-repo
download(repository, destination, options, callback)
Download a git
repository to a
destination folder with
The shorthand repository string to download the repository from:
- GitHub -
- GitLab -
- Bitbucket -
repository parameter defaults to the
master branch, but you can specify a branch or tag as a URL fragment like
In addition to specifying the type of where to download, you can also specify a custom origin like
Custom origin will default to
git@ for http and clone downloads respectively, unless protocol is specified.
Feel free to submit an issue or pull request for additional origin options.
In addition to having the shorthand for supported git hosts, you can also hit a repository directly with:
- Direct -
This will bypass the shorthand normalizer and pass
direct without clone, you must pass the full url to the zip file, including paths to branches if needed.
direct with clone, you must pass the full url to the git repo and you can specify a branch like
The file path to download the repository to.
An optional options object parameter with download options. Options include:
clone- boolean default
false- If true use
git cloneinstead of an http download. While this can be a bit slower, it does allow private repositories to be used if the appropriate SSH keys are setup.
- All other options (
filter, etc.) will be passed down accordingly and may override defaults
- Additional download options: https://github.com/kevva/download#options
- Additional clone options: https://github.com/jaz303/git-clone#clonerepo-targetpath-options-cb
The callback function as
Using http download from Github repository at master.
Using git clone from Bitbucket repository at my-branch.
Using http download from GitLab repository with custom origin and token.
Using git clone from GitLab repository with custom origin and protocol.
Note that the repository type (
gitlab etc.) is not required if cloning from a custom origin.
Using http download from direct url.
Using git clone from direct url at master.
Using git clone from direct url at my-branch.