如何在git中捆绑子模块更改? [英] How do you bundle submodule changes in git?

查看:58
本文介绍了如何在git中捆绑子模块更改?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有一个包含子模块的存储库,并且想为sneakernet创建捆绑包,如何使捆绑包包含更新子模块所需的对象?

If I have a repository that contains submodules, and I want to make a bundle for sneakernet, how do I make the bundle include the objects needed to update the submodules?

例如,假设我有一个名为 parent 的存储库,它包含一个名为 submod 的子模块.我想创建一个包,其中包含自提交 basecommit 以来的所有最新工作,因此,很自然地,我会从 parent 根目录内部进行操作:

For example, let's say I have a repository called parent and it contains a submodule called submod. I want to create a bundle that contains all the recent work since commit basecommit, so naturally, from inside the parent root directory I would do:

git bundle create mybundlefile.bundle basecommit..myworkingbranch

这将创建一个名为 mybundlefile.bundle 的文件,该文件包含 base 范围内的 parent 存储库中的所有提交对象,如下所示:以及参考 myworkingbranch .问题是,如果这些提交中的任何一个更改了子模块,那么生成的捆绑包将不是很有用,因为此类提交仅在更改子模块哈希时存储在捆绑包文件中.因此,存储在捆绑文件中的对象只是说:我提交 3ba024b ,并将子模块 submod 的哈希值从 2b941cf 更改为 1bb84ec ."但捆绑包实际上并不包含必要的对象 2b941cf..1bb84ec 来更新捆绑包中的子模块并为 myworkingbranch 创建干净的工作树.

This creates a file called mybundlefile.bundle that contains all the commit objects from the parent repo on the range basecommit..myworkingbranch as well as the ref myworkingbranch. The problem is that if any of those commits changed the submodule, the resultant bundle will not be very useful because such commits are only stored in the bundle file as changing the submodule hash. So the object stored in the bundle file just says "I'm commit 3ba024b and I change the hash of submodule submod from 2b941cf to 1bb84ec." but the bundle doesnt actually include the objects 2b941cf..1bb84ec necceassary to update the submodule from the bundle and make a clean working tree for myworkingbranch.

如何创建捆绑文件,以使子模块存储库中的所有那些对象也包括在内.也就是说,如果父仓库的基本提交 basecommit 将子模块 submod 指向哈希 A ,而父仓库的工作分支 myworkingbranch 将子模块 submod 指向哈希 B ,则我的捆绑包不仅需要包含 basecommit..myworkingbranch ,还需要包含 A..B .

How do I create the bundle file such that all those objects from the submodule repos are also included. That is, if the parents repo's base commit basecommit points submodule submod at hash A and the parent repo's working branch myworkingbranch points submodule submod at hash B, then my bundle needs to contain not only basecommit..myworkingbranch, but also A..B.

推荐答案

如何创建捆绑文件,以便也包括子模块存储库中的所有那些对象.

How do I create the bundle file such that all those objects from the submodule repos are also included.

不能.捆绑包文件特定于Git存储库.子模块只是指向另一个 Git存储库的链接,因此您必须为单独的Git存储库创建一个单独的包.(然后,您可以从各个捆绑包中进行归档.)

You can't. A bundle file is specific to a Git repository. A submodule is simply a link to another Git repository, so you must create a separate bundle for the separate Git repository. (You can then make an archive out of the various bundles.)

很明显,Git可以进入每个子模块并在每个这样的模块中运行 git bundle ,为您制作这些不同的文件.但是,传递给sub- git bundle 命令的参数很棘手.您将必须编写自己的脚本,并使用 git子模块foreach 使其在每个子模块中运行,并让脚本找出要使用的参数.

It's pretty clear that Git could descend into each submodule and run git bundle in each such one, making these various files for you. The arguments to pass to the sub-git bundle commands are tricky, though. You will have to write your own script and use git submodule foreach to get it to run in each submodule, and have your script figure out the parameters to use.

然后您可能希望将每个捆绑包打包在一起(大概打包成tar或rar或zip或其他档案),以进行运输和拆包/获取.在解除捆绑过程中,您将需要另一个 git子模块foreach ,这可能会更加烦人,因为理想情况下,这应该使用新的子模块集(在对顶层模块进行捆绑并选择适当的提交之后).

You will then probably want to package together each bundle (presumably into a tar or rar or zip or whatever archive) for transport and unbundling / fetching. You'll want another git submodule foreach during the unbundling, which will probably be even more annoying since ideally this should use the new set of submodules (after unbundling the top level one and selecting an appropriate commit).

某人可能已经编写了脚本来执行此操作,但是如果是这样,我就一无所知.Git本身不包含它-捆绑包本身有点笨拙且非主流y.

It's possible that someone has written scripts to do this, but if so, I don't know of it. It's not included in Git itself—bundles themselves are kind of klunky and non-mainstream-y.

这篇关于如何在git中捆绑子模块更改?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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