Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Commits in a git bundle

Tags:

git

git-bundle

Hy!

Is there a way to get a list of all commits stored in a git bundle without cloning it first?

Getting the heads is easy, but I couldn't find a way to get a full log out of it.

like image 972
mat Avatar asked Jan 22 '13 14:01

mat


People also ask

What does git bundle do?

Bundles are used for the "offline" transfer of Git objects without an active "server" sitting on the other side of the network connection. They can be used to create both incremental and full backups of a repository, and to relay the state of the references in one repository to another.

Does git bundle include tags?

git bundle will only package references that are shown by git show-ref: this includes heads, tags, and remote heads. References such as master~1 cannot be packaged, but are perfectly suitable for defining the basis. More than one reference may be packaged, and more than one basis can be specified.

Does git bundle include all branches?

Essentially, a bundle is an archive file that a user can use with the git clone command to create a local repository. The bundle contains your source code, as well as the change history for the commits and branches that you reference during the bundle creation step.

Can you push to a git bundle?

You cannot push directly to a bundle file. A bundle file is a compressed representation of a repository, and to modify it would involve unbundling, pushing, and bundling again. One way to do this is as you said, create a new bundle every time you want to make a backup.


1 Answers

Fetching from the bundle, as suggested in araqnid's answer, remains the easiest solution.

Anything else (meaning without cloning/fetching from the bundle) would involve decoding the git bundle format.
Which is slightly easier to do with Git 2.25.1 (Feb. 2020), since the technical details of the bundle format have been documented.

See commit 7378ec9 (07 Feb 2020) by Masaya Suzuki (draftcode).
(Merged by Junio C Hamano -- gitster -- in commit e99c325, 12 Feb 2020)
See discussion.

doc: describe Git bundle format

Signed-off-by: Masaya Suzuki

The bundle format was not documented. Describe the format with ABNF and explain the meaning of each part.

(ABNF: Augmented Backus–Naur form, a metalanguage based on Backus–Naur form (BNF), but consisting of its own syntax and derivation rule)

See Documentation/technical/bundle-format.txt for more:

bundle    = signature *prerequisite *reference LF pack
signature = "# v2 git bundle" LF

prerequisite = "-" obj-id SP comment LF
comment      = *CHAR
reference    = obj-id SP refname LF

pack         = ... ; packfile
like image 199
VonC Avatar answered Oct 12 '22 11:10

VonC