为什么我不能捆绑所有父母? [英] Why can't I git bundle all parents?

查看:66
本文介绍了为什么我不能捆绑所有父母?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建仅包含部分历史记录的git bundle。我运行以捆绑整个分支的命令是。 (参考

I'm trying to create a git bundle with only partial history. The command I run to bundle the entire branch is. (reference)

git bundle create my.bundle --all

但是,如果我只想将初始提交最多捆绑(不包括)特定的提交,则正确的rev-parse语法就是。 (参考

However if I want to only bundle the initial commit up to (not including) a specific commit the correct rev-parse syntax is. (reference)

git bundle create my.bundle dae86e1950b1277e545cee180551750029cfe735^@

但这失败git表示...

But this fails and git says...

fatal: Refusing to create empty bundle.

如何创建仅包含初始提交和所有历史记录(直至特定修订版本)的捆绑包?

How do I create bundle with only the initial-commit and all history up to some specific revision?

编辑

找到了这篇文章,其中解释了git bundle仅适用于标记(或其他参考,例如HEAD) )。但是我试图捆绑一些提交,但是 .. 的速记是排他的,不会包含初始提交。

I found this post which explains git bundle only works with a tag (or other reference like HEAD). However I'm trying to bundle a range of commits, but the .. shorthand is exclusive and wont include an initial commit.

推荐答案

简短的答案是,你不能-嗯,不是相当。本质上, git bundle git fetch 的服务器端:它会生成一个文件,您将其移交给 to git fetch 。客户端需要该文件包含服务器将传递给客户端的数据类型。

The short answer is that you can't—well, not quite. Essentially, git bundle is the server half of a git fetch: it builds a file that you literally hand over to git fetch later, when you have transported that file from the server to the client. The client needs that file to contain the kind of data that the server would pass to the client.

结果是捆绑文件必须包含:

The result is that the bundle file must contain:


  • 参考名称及其哈希ID列表,以及

  • git获取的对象将基于这些哈希ID减去

  • git fetch 不会的对象需要基于客户端的我已经有...哈希ID。

  • a list of reference names and their hash IDs, plus
  • the objects that git fetch would get based on those hash IDs, minus
  • the objects that git fetch would not need based on the client's "I already have ..." hash IDs.

在准备分发包时,参数您提供的是:

When preparing the bundle, the arguments you supply are:


  • 参考名称,以及

  • 基础如果客户端能够直接连接,客户端将提供的哈希ID。

  • the reference names, and
  • the basis hash IDs that the client would have provided, had the client been able to connect directly.

在此列表中没有任何内容-您-provide可以使用 rev ^ @ 样式的引用。

Nowhere in this list of things-you-provide is there the ability to use rev^@-style references.

您可以做什么 是将引用名称附加到每个软管头:

What you can do is attach reference names to each of those heads:

for parent in $(git rev-parse ${rev}^@); do
    git tag bundle-p$parent $parent
done

现在实际引用名称(轻量标签)指向您要执行要包含在捆绑软件中的每个提交。现在假设没有其他以 bundle开头的标签,您现在可以提供-tags ='bundle-p *'作为一组正引用。 -p 。 (您可以在以后删除标签以保持此不变性。如果更方便,可以使用-branches ='bundle-p *'代替分支名称。 。)

Now you have actual reference names (lightweight tags) pointing to each of the commits that you do want to include in the bundle. You can now supply --tags='bundle-p*' as a set of positive refs, assuming there are no other tags that begin with bundle-p. (You can delete the tags afterward to maintain this invariant. You can use branch names instead, with --branches='bundle-p*', if that's more convenient for you.)

(请注意,将 $ {rev} ^ @ 应用于根提交不会产生任何输出。 。这表示在这种情况下将没有 bundle-p * 标签。)

(Be aware that ${rev}^@ will produce no output when applied to a root commit. This means there will be no bundle-p* tags for this case.)

如果您的特定停止- point是普通的(单亲)提交,您只需在 $ {rev} ^ 上附加一个引用名称即可。在所有情况下,您都必须在要做要包含在捆绑包中的端点提交上附加引用名称。

If your particular stop-point is an ordinary (single-parent) commit, you can just attach a single reference name to ${rev}^. In all cases, you must attach a reference name to the end-point commits that you do want to have in the bundle.

这篇关于为什么我不能捆绑所有父母?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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