如何在 "git clone --depth=1" 之后获得完整的 git 历史记录?

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

我的一个 git 存储库很大,包含以前提交的大量资产。

我以某种方式能够使用 git clone <repo> --depth=1.

克隆 repo(使其可运行)

我想在同一个本地仓库中获取所有以前的提交。

谢谢。

git pull --unshallow应该做到。

来自 (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--depth--deepen=--shallow-since 也可能相关。

来自 (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 指出以下几点:

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 do I "undo" a --single-branch clone? 中显示了如何操作。