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.


Hope you found this post useful. It was published . Please show your love and support by sharing this post.