{"id":24617734,"url":"https://github.com/jacoblincool/dlgit","last_synced_at":"2026-04-16T11:32:06.261Z","repository":{"id":40351536,"uuid":"491361760","full_name":"JacobLinCool/dlgit","owner":"JacobLinCool","description":"Download part of a git repository without wasting your bandwidth.","archived":false,"fork":false,"pushed_at":"2023-12-15T14:56:05.000Z","size":420,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-18T12:22:54.517Z","etag":null,"topics":["api","cli","download","git"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/dlgit","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/JacobLinCool.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-05-12T04:21:04.000Z","updated_at":"2022-05-12T18:10:09.000Z","dependencies_parsed_at":"2022-08-09T18:00:14.632Z","dependency_job_id":null,"html_url":"https://github.com/JacobLinCool/dlgit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fdlgit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fdlgit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fdlgit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JacobLinCool%2Fdlgit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JacobLinCool","download_url":"https://codeload.github.com/JacobLinCool/dlgit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244308691,"owners_count":20432251,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","cli","download","git"],"created_at":"2025-01-24T23:40:20.615Z","updated_at":"2026-04-16T11:32:06.212Z","avatar_url":"https://github.com/JacobLinCool.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# dlgit\n\nDownload part of a git repository without wasting your bandwidth.\n\n[NPM Package](https://www.npmjs.com/package/dlgit) | [GitHub Repository](https://github.com/JacobLinCool/dlgit) | [Documentation](https://jacoblincool.github.io/dlgit/)\n\n![DEMO](./demo/demo.gif)\n\n## Why \u0026 How\n\n`dlgit` can download only part of a git repository and reduce the time and bandwidth you spend downloading the whole repository.\n\n`dlgit` does the followings:\n\n1. serve the files from the local cache if they are available.\n2. `git clone` with optimized options.\n    - `--filter=blob:none` to avoid downloading all file contents.\n    - `--no-checkout` to avoid automatically checking out the files.\n    - `--depth=1` to avoid downloading history of the repository.\n3. setup `sparse-checkout` to only download the files that are required.\n4. `git checkout` to check out the files you need.\n5. remove `.git` directory to avoid messing up the files.\n6. cache the files in the local cache.\n\n## Usage\n\n### Install Globally\n\n```sh\nnpm i -g dlgit\ndlgit --help\n\n# dg --help\n# this should work as well since dg is the alias of dlgit\n```\n\n```sh\ndg --sub /packages/create-vite/template-vue-ts \"vitejs/vite#v2.9.9\"\n# download the files in the subdirectory `packages/create-vite/template-vue-ts` in \n# tag `v2.9.9` of the GitHub repository `vitejs/vite`\n```\n\n### Just Run\n\n```sh\nnpx dlgit --help\n```\n\n```sh\nnpx dlgit --sub /public \"https://gitlab.noj.tw/noj/codebase/frontend.git#readme\"\n# download the files in the subdirectory `public` in \n# branch `readme` of the repository `https://gitlab.noj.tw/noj/codebase/frontend.git`\n```\n\n## Help\n\n```sh\n❯ dlgit -h\nUsage: dlgit [options] [command] \u003cremote\u003e\n\nArguments:\n  remote                 Remote repository to download from (e.g. Open-OJ/3OJ#gh-pages)\n\nOptions:\n  -V, --version          output the version number\n  -s, --sub \u003cdir\u003e        Subdirectory to download\n  -c, --cache \u003ccache\u003e    Cache directory\n  -T, --ttl \u003cttl\u003e        Cache TTL (ms)\n  -t, --to \u003cto\u003e          Destination directory\n  -f, --force            Overwrite existing directory if it exists\n  -h, --help             display help for command\n\nCommands:\n  clear-cache [options]  Clear the cache\n  parse \u003cremote\u003e         Parse remote repository location\n```\n\n## API\n\nIt supports both `ESM` and `CJS` modules.\n\n```ts\nimport Dlgit from \"dlgit\";\n\nconst dlgit = new Dlgit();\ndlgit.dl(\"Open-OJ/3OJ#gh-pages\", {\n    sub: \"problems\",\n    cache: \"cache-dir\",\n    ttl: 1000 * 60 * 60 * 24,\n    to: \"destination-dir\"\n});\n// all options are optional\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoblincool%2Fdlgit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjacoblincool%2Fdlgit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjacoblincool%2Fdlgit/lists"}