Search code examples
gitgit-commit

How to get whole git history afterwards "git clone --depth=1"?


One of my git repo was huge, containing huge assets to previous commits.

Somehow I was able to clone repo(made runnable) using git clone <repo> --depth=1.

I want to get all the previous commits on same local repo.

Thank You.


Solution

  • git pull --unshallow should do it.

    From (git-scm)

    --unshallow

    If the source repository is complete, convert a shallow repository to a >complete one, removing all the limitations imposed by shallow repositories.

    If the source repository is shallow, fetch as much as possible so that the >current repository has the same history as the source repository.

    pull's --depth, --deepen= and --shallow-since may also be relevant.

    From (git-scm)

    --depth=<depth>

    Limit fetching to the specified number of commits from the tip of each remote branch history. If fetching to a shallow repository created by git clone with --depth= option (see git-clone[1]), deepen or shorten the history to the specified number of commits. Tags for the deepened commits are not fetched.

    --deepen=<depth>

    Similar to --depth, except it specifies the number of commits from the >current shallow boundary instead of from the tip of each remote branch history.

    --shallow-since=<date>

    Deepen or shorten the history of a shallow repository to include all reachable commits after <date>.


    git guru @torek points out the following:

    Be aware that a clone made with --depth is also, by default, a single-branch clone. To make it a full clone you will need to undo this single branch effect.

    How to do it is shown at How do I "undo" a --single-branch clone?.