Shallow clone
Definition
A Git clone takes over only a limited section of the version history.
A shallow clone is a Git repository with a shortened commit history. When cloning, the depth can be limited, for example, with --depth. This can reduce data retrieval but restricts historical analyses. Needed older history can be fetched later under appropriate conditions.
Simply explained
You fetch the most recent chapters of the project history instead of the entire book. For older contexts, you must request additional chapters.
Why it matters in practice
Automated builds can start with less data transfer effort, provided their checks do not require the full version history or older tags.
Example from business
Possible example: A build pipeline fetches only a limited commit history, while a tool for version comparisons fetches the required history before execution.
Limits and pitfalls
- History-based checks and version calculations may be missing or make incorrect assumptions. Shallow clone is not the same as selecting individual project files.
Origin & history
Git supplements full clones with options for limited histories, enabling tailored data volumes for specific workflows.
Use in mid-sized companies
- A company can check for each pipeline which history it needs and deliberately set the clone depth instead of always using the smallest scope everywhere.
Frequently asked questions
Can a shallow clone be expanded later?
Yes. Git fetch offers options to deepen or complete the history, as long as the remote provides the required history.
Sources
- git-fetch. · Git (o. J.): git-fetch.
Editorially reviewed on: