Check if Git Repository is Shallow

Check if Git Repository is Shallow

A shallow Git repository is a repository that contains only part of its commit history, rather than the complete history of the project. Shallow clones are often created to reduce download size and speed up operations when the full commit history is unnecessary. Identifying a shallow repository can be useful in build scripts. This tutorial explains how to check if Git repository is shallow.

The git rev-parse command with the --is-shallow-repository option determines whether the current Git repository has a limited commit history. The command outputs true if the repository is shallow and false if the complete history is available.

git rev-parse --is-shallow-repository

Leave a Comment

Cancel reply

Your email address will not be published.