3

I am trying to create a bundle file from commit x to commit y. As specified on git bundle's documentation the arguments have to be "acceptable to git rev-parse and git rev-list ..., that specifies the specific objects and references to transport" However, when I run the following command:

git bundle create test.bundle 15b423..6cffeab

I get the error

error: Refusing to create empty bundle.

Then I verified that the commits could be referenced by rev-list and 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

Why it doesn't work? How can I create a bundle file that ranges from commit A to commit B ?

Anika
  • 398
  • 5
  • 23

2 Answers2

3

From git bundle documentation (under Specifying References): "git bundle will only package references that are shown by git show-ref: this includes heads, tags, and remote heads." So if you added tags to those commits, your command should work.

I do agree that the line that you quoted makes it seem like your command would work, IMHO that's not very clear.

  • Creating the tags worked, thanks! Although it creates repository with a detached HEAD. – Anika Mar 02 '17 at 14:10
  • And in general, the baseline can be a commit hash rather than a branchname. Only the target needs you to create some branchname first. – TamaMcGlinn Sep 21 '20 at 13:12
1

With Git 2.34 (Q4 2021), the git bundle documentation is clearer, and include your usecase:

See commit 1d9c8da, commit 0bb92f3, commit 9ab80dd, commit 5c8273d (31 Jul 2021) by Ævar Arnfjörð Bjarmason (avar).
(Merged by Junio C Hamano -- gitster -- in commit f19b275, 24 Aug 2021)

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 now includes in its 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.
----------------
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250