Skip to main content

Module blob

Module blob 

Source
Expand description

In Git, a blob (binary large object) is a type of Git object that stores the contents of a file. A blob object contains the binary data of a file, but does not contain any metadata such as the file name or permissions. The structure of a Git blob object is as follows:

blob <content-length>\0<content>
  • blob is the object type, indicating that this is a blob object.
  • <content-length> is the length of the content in bytes, encoded as a string of decimal digits.
  • \0 is a null byte, which separates the header from the content.
  • <content> is the binary data of the file, represented as a sequence of bytes.

We can create a Git blob object for this file by running the following command:

$ echo "Hello, world!" | git hash-object -w --stdin

This will output an SHA-1/ SHA-256 hash, which is the ID of the newly created blob object. The contents of the blob object would look something like this:

blob 13\0Hello, world!

Git uses blobs to store the contents of files in a repository. Each version of a file is represented by a separate blob object, which can be linked together using Git’s commit and tree objects to form a version history of the repository.

Structs§

Blob
The Blob Object