How to Convert a Shallow Cloned Repository to a Full Clone?

You can convert a shallow clone of a repository to a full clone in the following steps:

  1. Navigate to the directory of the shallow cloned repository;
  2. (Optional) Verify that the repository is indeed shallow;
  3. Fetch all the missing objects and references from the remote repository;
  4. (Optional) Verify that the repository is no longer shallow.

These steps translate to the following commands in terminal:

# 1: navigate to directory of shallow cloned repo
$ cd path/to/shallow-cloned-repo

# 2: verify repo is shallow
$ git rev-parse --is-shallow-repository

# 3: fetch missing objects and references from remote
$ git fetch --unshallow

# 4: verify repo is not shallow
$ git rev-parse --is-shallow-repository

This works by performing a "deepening" operation by fetching all the missing objects and references from the remote repository, converting your shallow cloned repository to a full clone. Doing so will allow you to access the complete history and all branches of the repository.


This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.