When cloning open-source repositories from GitHub, especially popular ones, it can take a minute. This delay happens because Git fetches all commits in the main
branch from the beginning.
Shallow Clone
A shallow clone is essentially cloning only the latest snapshot of the repository. You can do this by passing --depth
option as below.
git clone --depth 1 <repository_url>
This is helpful when you need only the latest commit and don't need the full commit history. It’s particularly beneficial when working with large repositories.
After performing a shallow clone using depth
, you can run git log
to see the number of commits it fetched.
You can read more about git depth in Git Documentation.
Top comments (0)