如何将 Git 浅克隆转换为完整克隆?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6802145/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:24:27  来源:igfitidea点击:

How to convert a Git shallow clone to a full clone?

gitclone

提问by Mot

Follow-up of thisso-question: if I have a shallow clone, how to fetch all older commits to make it a full clone?

这个问题的后续:如果我有一个浅克隆,如何获取所有旧提交以使其成为完整克隆?

采纳答案by svick

EDIT:git fetch --unshallownow is an option (thanks Hyman O'Connor).

编辑:git fetch --unshallow现在是一个选择(感谢Hyman奥康纳)。

You can run git fetch --depth=1000000(assuming the repository has less than one million commits).

您可以运行git fetch --depth=1000000(假设存储库的提交少于一百万次)。

回答by Ramkumar D

The below command (git version 1.8.3)will convert the shallow clone to regular one

下面的命令(git 版本 1.8.3)会将浅克隆转换为常规克隆

git fetch --unshallow

Then, to get access to all the branches on origin (thanks @Peter in the comments)

然后,要访问原点上的所有分支(感谢评论中的@Peter)

git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch origin

回答by Victor Sergienko

I needed to deepen a repo only down to a particular commit.

我只需要将 repo 深化到特定的提交。

After reading man git-fetch, I found out that one cannot specify a commit, but can specify a date:

看了之后man git-fetch发现不能指定提交,但是可以指定日期:

git fetch --shallow-since=15/11/2012

For those who need incremental deepening, another manquote:

对于那些需要渐进式深化的人,另一个man引用:

--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.

--deepen=<depth>

与 --depth 类似,除了它指定从当前浅边界而不是从每个远程分支历史记录的尖端的提交次数。

回答by Altynai

You can try this:

你可以试试这个:

git fetch --update-shallow

回答by Gen.Stack

None of the above messages did the trick. I'm trying to work with git tags starting from a shallow clone.

上述消息都没有起到作用。我正在尝试从浅层克隆开始使用 git 标签。

First I tried

首先我试过

git fetch --update-shallow

which kind of worked half-way through. Yet, no tags available!

哪种工作中途。然而,没有可用的标签!

git fetch --depth=1000000

This last command really fetched the tags and I could finally execute

最后一个命令确实获取了标签,我终于可以执行了

git checkout -b master-v1.1.0 tags/v1.1.0

and be done with it.

并完成它。

HTH

HTH