使浅的GIT存储库变浅 [英] Make a shallow GIT repository less shallow

查看:77
本文介绍了使浅的GIT存储库变浅的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为指定标签创建浅表克隆:

I create a shallow clone for a specified tag:

git clone --branch v0.1.3 --depth 1 file:///c/usr/sites/smc .

此后,克隆的回购中仅包含标签v0.1.3(及相关文件)。
它没有该标记之前或之后的所有更改的历史记录(据我所知-如果错误,请更正。)
接下来,我想更新克隆以包括v0.1.4。
如果我使用 git fetch --unshallow命令,则会得到完整的历史记录,而这是我所不希望的。
是否可以扩展克隆以包含来自主服务器的较新历史记录(如v0.1.4和0.1.5),而不包括较旧的历史记录(如0.1.2)? (我看到一个称为update-shallow的选项,但不了解它的功能或它是否相关。)

After this the cloned repo only has the tag v0.1.3 (and associated files) in it. It does not have the history for all the changes before or after that tag (as I understand - correct me if wrong.) Next I would like to update the clone to include v0.1.4. If I use a "git fetch --unshallow" command, then I get the full history, which I do not want. Is there a way to expand my clone to include newer history from the master (like v0.1.4 and 0.1.5), but not older history (like 0.1.2)? (I see an option called update-shallow, but do not understand what it does or whether it is relevant.)

此操作的目标是:

1)通过不克隆整个存储库,使远程服务器上存储库的初始设置既快速又小。 (我们的存储库主要是二进制文件:DLL,EXE。)

1) Make the initial setup of the repository on the remote server fast and small by not cloning the whole repo. (Our repo is mostly binaries: DLLs, EXEs.)

2)可以将远程存储库升级到更高版本(如标记所给),但从未升级过版本。这样的升级只会转移一部分存储库,因此它也应该很快。

2) Make it possible to upgrade the remote repo to later versions (as given by the tag) but never earlier versions. Such an upgrade will only transfer a fraction of the repository, so it should also be fast.

注意:在Windows 7上,我的Git版本是1.9.2.msysgit.0。这包括最近对浅克隆的增强。
我们可能会在Linux上托管主存储库,但是我们要部署到的代理运行Windows。
目的是使用人偶企业管理结帐。

NOTE: My Git version is 1.9.2.msysgit.0 on Windows 7. This includes the recent enhancements to shallow cloning. We will likely host the main repository on Linux, but the agents to which we deploy run Windows. The intent is to manage checkouts using puppet enterprise.

更新:
尝试了VonC的建议。

UPDATE: Tried VonC's suggestion.

$ git fetch --update-shallow origin v0.1.4
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (4/4), done.
From file:///c/usr/sites/smc
 * tag               v0.1.4     -> FETCH_HEAD

paul.chernoch@USB-XXXXXXXXX /c/usr/sites/smc-clone3 ((v0.1.3))
$ git describe
v0.1.3

paul.chernoch@USB-XXXXXXXXX /c/usr/sites/smc-clone3 ((v0.1.3))
$ git tag --list
v0.1.3

虽然该命令似乎可以执行某些操作,但在目标存储库中看不到标记v0.1.4。但是,如果我使用--tags选项,则可以获取所有标签以及所有历史记录!
另外,我不理解git fetch命令输出中的符号 FETCH_HEAD。

While the command seemed to do something, I do not see the tag v0.1.4 in my target repo. However, if I use the --tags option, I get all the tags, but also all the history! Also, I do not understand the notation "FETCH_HEAD" in the output of the git fetch command.

更新:
进一步的研究表明,这样的问题是在类似的目标之后:
git浅克隆到特定标签

推荐答案

似乎我对此有类似的疑问,然后才发现。诀窍是在fetch命令的末尾和深度处指定完整的refspec。 refs / tags / v0.1.3:refs / tags / v0.1.3或简称v0.1.3

Seems I had a similar question to this and found this afterwards. The trick was to specify the full refspec at the end and depth on the fetch command. refs/tags/v0.1.3:refs/tags/v0.1.3 or tag v0.1.3 for short

对新标签进行Git浅取

git fetch --depth 1 origin tag v0.1.4

这篇关于使浅的GIT存储库变浅的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆