尝试创建介于 2 次提交之间的 git 包时出错
Error trying to create a git bundle ranged between 2 commits
我正在尝试创建一个从提交 x 到提交 y 的捆绑文件。
正如在 git bundle's documentation 上指定的那样,参数必须是“ 可接受的 git rev-parse 和 git rev-list ...,它指定了特定的对象和引用运输”
但是,当我 运行 以下命令时:
git bundle create test.bundle 15b423..6cffeab
我收到错误
error: Refusing to create empty bundle.
然后我验证了 rev-list 和 rev-parse 可以引用提交:
ana@DESKTOP-K400GGC MINGW64 ~/Projects/TEST1 ((20dc3fd...))
$ git rev-list 15b423b 6cffeab
6cffeabc7e3183fcca8cb8b91eecbf9e0af5a0e7
beb6fb7cfda467433cb2cdab362a25178b1ddf18
458cfcd0064b229f8b416d65405f18732d8c359a
53c90498e13edd32248842b3fd4fb7819041a1d6
ba087013804d4a39b36f3e679548fb45fe9645fb
ad1b1fde27be98b5b09d8e5a43137d16fd6e1840
540da9dea1b816a20be11e5c53b94467449266af
aa64d78ab5c990b047711b9f81fdae13beb27a05
15b423b91a63c403fe0ee0f3365c9846f37f3aa4
ana@DESKTOP-K400GGC MINGW64 ~/Projects/TEST1 ((20dc3fd...))
$ git rev-parse 15b423..6cffeab
6cffeabc7e3183fcca8cb8b91eecbf9e0af5a0e7
^15b423b91a63c403fe0ee0f3365c9846f37f3aa4
为什么不起作用?如何创建范围从提交 A 到提交 B 的捆绑文件?
来自 git 包文档(在指定引用下):
"git bundle will only package references that are shown by git show-ref: this includes heads, tags, and remote heads." 因此,如果您向这些提交添加了标签,您的命令应该会起作用。
我同意你引用的那一行让你的命令看起来好像可以工作,恕我直言,这不是很清楚。
使用 Git 2.34(2021 年第 4 季度),git bundle
文档更加清晰,并包括您的用例:
参见 commit 1d9c8da, commit 0bb92f3, commit 9ab80dd, commit 5c8273d (31 Jul 2021) by Ævar Arnfjörð Bjarmason (avar
)。
(由 Junio C Hamano -- gitster
-- in commit f19b275 合并,2021 年 8 月 24 日)
bundle doc
: elaborate on rev<->ref restriction
Signed-off-by: Ævar Arnfjörð Bjarmason
Elaborate on the restriction that you cannot provide a revision that doesn't resolve to a reference in the "SPECIFYING REFERENCES
" section with examples.
git bundle
现在包含在其 man page 中:
Revisions must accompanied by reference names to be packaged in a
bundle.
More than one reference may be packaged, and more than one basis can
be specified. The objects packaged are those not contained in the
union of the given bases.
The 'git bundle create' command resolves the reference names for you
using the same rules as git rev-parse --abbrev-ref=loose
. Each
basis can be specified explicitly (e.g. ^master~10
), or implicitly
(e.g. master~10..master
, --since=10.days.ago master
).
All of these simple cases are OK (assuming we have a "master" and
"next" branch):
----------------
$ git bundle create master.bundle master
$ echo master | git bundle create master.bundle --stdin
$ git bundle create master-and-next.bundle master next
$ (echo master; echo next) | git bundle create master-and-next.bundle --stdin
----------------
And so are these (and the same but omitted --stdin
examples):
----------------
$ git bundle create recent-master.bundle master~10..master
$ git bundle create recent-updates.bundle master~10..master next~5..next
----------------
A revision name or a range whose right-hand-side cannot be resolved to
a reference is not accepted:
----------------
$ git bundle create HEAD.bundle $(git rev-parse HEAD)
fatal: Refusing to create empty bundle.
$ git bundle create master-yesterday.bundle master~10..master~5
fatal: Refusing to create empty bundle.
----------------
我正在尝试创建一个从提交 x 到提交 y 的捆绑文件。 正如在 git bundle's documentation 上指定的那样,参数必须是“ 可接受的 git rev-parse 和 git rev-list ...,它指定了特定的对象和引用运输” 但是,当我 运行 以下命令时:
git bundle create test.bundle 15b423..6cffeab
我收到错误
error: Refusing to create empty bundle.
然后我验证了 rev-list 和 rev-parse 可以引用提交:
ana@DESKTOP-K400GGC MINGW64 ~/Projects/TEST1 ((20dc3fd...))
$ git rev-list 15b423b 6cffeab
6cffeabc7e3183fcca8cb8b91eecbf9e0af5a0e7
beb6fb7cfda467433cb2cdab362a25178b1ddf18
458cfcd0064b229f8b416d65405f18732d8c359a
53c90498e13edd32248842b3fd4fb7819041a1d6
ba087013804d4a39b36f3e679548fb45fe9645fb
ad1b1fde27be98b5b09d8e5a43137d16fd6e1840
540da9dea1b816a20be11e5c53b94467449266af
aa64d78ab5c990b047711b9f81fdae13beb27a05
15b423b91a63c403fe0ee0f3365c9846f37f3aa4
ana@DESKTOP-K400GGC MINGW64 ~/Projects/TEST1 ((20dc3fd...))
$ git rev-parse 15b423..6cffeab
6cffeabc7e3183fcca8cb8b91eecbf9e0af5a0e7
^15b423b91a63c403fe0ee0f3365c9846f37f3aa4
为什么不起作用?如何创建范围从提交 A 到提交 B 的捆绑文件?
来自 git 包文档(在指定引用下): "git bundle will only package references that are shown by git show-ref: this includes heads, tags, and remote heads." 因此,如果您向这些提交添加了标签,您的命令应该会起作用。
我同意你引用的那一行让你的命令看起来好像可以工作,恕我直言,这不是很清楚。
使用 Git 2.34(2021 年第 4 季度),git bundle
文档更加清晰,并包括您的用例:
参见 commit 1d9c8da, commit 0bb92f3, commit 9ab80dd, commit 5c8273d (31 Jul 2021) by Ævar Arnfjörð Bjarmason (avar
)。
(由 Junio C Hamano -- gitster
-- in commit f19b275 合并,2021 年 8 月 24 日)
bundle doc
: elaborate on rev<->ref restrictionSigned-off-by: Ævar Arnfjörð Bjarmason
Elaborate on the restriction that you cannot provide a revision that doesn't resolve to a reference in the "
SPECIFYING REFERENCES
" section with examples.
git bundle
现在包含在其 man page 中:
Revisions must accompanied by reference names to be packaged in a bundle.
More than one reference may be packaged, and more than one basis can be specified. The objects packaged are those not contained in the union of the given bases.
The 'git bundle create' command resolves the reference names for you using the same rules as
git rev-parse --abbrev-ref=loose
. Each basis can be specified explicitly (e.g.^master~10
), or implicitly (e.g.master~10..master
,--since=10.days.ago master
).All of these simple cases are OK (assuming we have a "master" and "next" branch):
---------------- $ git bundle create master.bundle master $ echo master | git bundle create master.bundle --stdin $ git bundle create master-and-next.bundle master next $ (echo master; echo next) | git bundle create master-and-next.bundle --stdin ----------------
And so are these (and the same but omitted
--stdin
examples):---------------- $ git bundle create recent-master.bundle master~10..master $ git bundle create recent-updates.bundle master~10..master next~5..next ----------------
A revision name or a range whose right-hand-side cannot be resolved to a reference is not accepted:
---------------- $ git bundle create HEAD.bundle $(git rev-parse HEAD) fatal: Refusing to create empty bundle. $ git bundle create master-yesterday.bundle master~10..master~5 fatal: Refusing to create empty bundle. ----------------