Git Object Formats and Transfer
How object IDs are formed
For a blob, Git hashes a header of the form blob, space, decimal byte count, NUL, followed by content bytes. SHA-1 repositories use 40 hexadecimal characters and SHA-256 repositories use 64. This is not merely hashing the file bytes. Tree, commit and tag payloads also encode references to other objects, so changing hash format changes more than display length.
Compare formats in separate repositories
The manual guide creates two independent fixtures, one for each object format. Run these commands within each respective repository. The same exact bytes produce different IDs across formats. Verify the format rather than guessing from an abbreviated hash. Do not change extensions.objectFormat to convert an existing repository; support for interoperation depends on the Git version and endpoints.
git rev-parse --show-object-formatprintf "Garden\n" | git hash-object --stdinTransfer and storage are separate
A pack may store compressed objects or deltas plus an index for lookup. During fetch, peers discover refs and negotiate objects they need and already possess; supported capabilities and protocol versions affect this process. The reconstructed object retains its identity. A pack checksum is not a commit signature or proof of authorization.
Practice and check
Clone each format using the matching local file source in the manual lab. Compare the destination HEAD and its object format with the source. After a new source commit, fetch and verify origin/main without advancing the checked-out branch. These tests establish local compatible transport behavior only; they do not establish GitHub SHA-256 support or inspect protocol packets.
git rev-parse --show-object-formatgit rev-parse HEAD origin/maingit cat-file -t origin/mainCheck Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Git Object Formats and Transfer — knowledge check
Reason about Git objects, index and reference state.
What is hashed for an ordinary blob?
How many hex characters are in a full SHA-256 object ID?
Do equal blob bytes have the same ID across SHA-1 and SHA-256?
What does fetch negotiation help determine?
What does the local SHA-256 transport test establish?