{"id":21560481,"url":"https://github.com/lu0/git-partial-clone","last_synced_at":"2025-08-02T18:06:25.891Z","repository":{"id":132823498,"uuid":"405523235","full_name":"lu0/git-partial-clone","owner":"lu0","description":"Effortlessly clone specific subdirectories of Git repositories.","archived":false,"fork":false,"pushed_at":"2021-10-17T10:14:36.000Z","size":53,"stargazers_count":4,"open_issues_count":4,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-18T04:32:39.486Z","etag":null,"topics":["cli","clone","git","git-partial-clone","hacktoberfest","linux","partial","partial-clone","script"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lu0.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-09-12T01:57:56.000Z","updated_at":"2023-10-17T04:53:55.000Z","dependencies_parsed_at":"2023-03-20T22:20:06.184Z","dependency_job_id":null,"html_url":"https://github.com/lu0/git-partial-clone","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/lu0/git-partial-clone","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lu0%2Fgit-partial-clone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lu0%2Fgit-partial-clone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lu0%2Fgit-partial-clone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lu0%2Fgit-partial-clone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lu0","download_url":"https://codeload.github.com/lu0/git-partial-clone/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lu0%2Fgit-partial-clone/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268431633,"owners_count":24249411,"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","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["cli","clone","git","git-partial-clone","hacktoberfest","linux","partial","partial-clone","script"],"created_at":"2024-11-24T09:15:15.290Z","updated_at":"2025-08-02T18:06:25.882Z","avatar_url":"https://github.com/lu0.png","language":"Shell","readme":"`git-partial-clone`\n---\n\nThis script clones a subdirectory of a github/gitlab repository.\n\n- [Install](#install)\n- [Using the comand line options](#using-the-comand-line-options)\n  - [Clone from public repositories](#clone-from-public-repositories)\n  - [Clone from private repositories](#clone-from-private-repositories)\n- [Using a configuration file](#using-a-configuration-file)\n  - [Configuration variables](#configuration-variables)\n    - [Mandatory variables](#mandatory-variables)\n    - [Variables for **private repositories**](#variables-for-private-repositories)\n    - [Optional variables](#optional-variables)\n- [Docker](#docker)\n\n# Install\nInstall the script and autocompletion rules.\n```zsh\n./install.sh\n```\nThen you can call the command `git-partial-clone` from any directory and use `TAB` to autocomplete the CLI options.\n\n# Using the comand line options\nRun with the `--help` flag to see the complete list of options (recommended). Or read the following sections to clone using the most common options.\n```\n$ git-partial-clone -h\n\nClone a subdirectory of a github/gitlab repository.\n\nUSAGE:\n   git-partial-clone   [OPTIONS] ARGUMENTS\n   git-partial-clone   # Or assume config variables in shell.\n\nOPTIONS:\n            --help     Show this manual.\n\n   Using a config file:\n       -f | --file     Path to the configuration file.\n\n   CLI options (mandatory):\n       -o | --owner    Author (owner) of the repository.\n       -r | --repo     Name of the repository.\n\n   CLI options (optional):\n       -h | --host     github (default) or gitlab.\n       -s | --subdir   Subfolder to be cloned.\n\n       -t | --token    Path to your access token (for private repos).\n\n       -b | --branch   Branch to be fetched.\n       -v | --tag      Tag of the version to be fetched.\n       -d | --depth    Number of commits to be fetched.\n```\n\n## Clone from public repositories\nProvide the mandatory options `--repo`, `--owner` and the subdirectory (`--subdir`) you want to clone.\n\nThe following example clones a subfolder of my [vscode-settings](https://github.com/lu0/vscode-settings/tree/master/json/snippets) repository.\n```zsh\ngit-partial-clone --owner=lu0 --repo=vscode-settings --subdir=json/snippets\n```\n\nYou can also clone the entire repository, although this is not the intended use.\n```zsh\ngit-partial-clone --owner=lu0 --repo=vscode-settings\n```\n\n## Clone from private repositories\nYou will need to generate an access token in order to clone private repositories, as password authentication is deprecated.\n\n- Github: [github.com/settings/tokens](https://github.com/settings/tokens).\n- Gitlab: [gitlab.com/-/profile/personal_access_tokens](https://gitlab.com/-/profile/personal_access_tokens).\n\nSave your token in a file and provide its path with the `--token` option, the following example would clone a subfolder of a private repository.\n```zsh\ngit-partial-clone --owner=owner --repo=repo --subdir=path/to/subdir \\\n    --token=/path/to/your/token/file\n```\n\n# Using a configuration file\nUsing a configuration file will give you more control over the objects you're cloning. You can test this functionality with the provided configuration file:\n```zsh\ngit-partial-clone --file=example.conf\n```\nBy the end of the execution, you will see a `tmp` directory containing the subfolder of the example repository.\n\n## Configuration variables\nFill in the config file ([`template.conf`](./template.conf)) with the information of the repository you're cloning. You can see the example file [here](./example.conf).\n\n### Mandatory variables\n\n- `GIT_HOST`:\n    - `github` if the repository is hosted on Github.\n    - `gitlab` if the repository is hosted on Gitlab.\n- `REPO_OWNER`:\n    - Username of the owner/author of the repository.\n- `REPO_NAME`:\n    - Name of the repository to be cloned.\n- **`REMOTE_PARTIAL_DIR`**:\n    - **Subdirectory of the repository you want to clone**.\n    - Omit it to clone the entire repository.\n\n### Variables for **private repositories**\n- `TOKEN_PATH`:\n    - Path to the file containing the access token.\n\n### Optional variables\n- `BRANCH`:\n    - The branch to be fetched.\n    - Omit it to pull all of the branches and switch to the default one.\n- `TAG_NAME`:(tag | t)\n    - Tag of the version to be fetched.\n    - Omit it to fetch the latest commit of `BRANCH`.\n    - Set `BRANCH` to search for tags in a specific branch.\n- `COMMIT_DEPTH`:\n    - Number of commits you want to fetch (useful for deployment purposes).\n    - Omit it to fetch the entire remote history.\n- `PARENT_DIR`:\n    - Path to the target parent directory.\n    - Omit it to clone the repository in the current directory.\n \n# Docker\nYou can use the provided  [docker image](https://hub.docker.com/repository/docker/lu0alv/git-partial-clone) to create rolling or stable releases of your repositories.\n\n1. Fill your ([configuration file](#configuration-variables)) according to your needs.\n2. Add your entrypoint script in your dockerfile:\n\n```docker\nFROM lu0alv/git-partial-clone:latest\n\n.\n.\n.\n\nENTRYPOINT [\"/bin/sh\", \"-c\" , \"get-source \u0026\u0026 exec /home/${PARENT_DIR}/${REPO_NAME}/${REMOTE_PARTIAL_DIR}/deploy.sh\"]\n```\n\n3. Then run your dockerfile by providing your configuration file and mounting the file containing your github/gitlab token:\n\n```zsh\nCONFIG_FILE=/path/to/your/config-file.conf\nsource $CONFIG_FILE\ndocker run \\\n    --env-file ${CONFIG_FILE} \\\n    -v /path/to/your/existing/token-file:${TOKEN_PATH} \\\n    # your extra options and dockerfile\n```\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flu0%2Fgit-partial-clone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flu0%2Fgit-partial-clone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flu0%2Fgit-partial-clone/lists"}