git hash-object
A low-level command that prints the object ID Git would give some content, and can store it with -w.
In more detail
git hash-object report.md shows the blob ID for that file, and --stdin reads the content from standard input instead. With -t commit it hashes text as a commit, which proves a commit ID is simply the hash of the commit's text.
Example
printf 'Revenue is up.\n' | git hash-object --stdinRelated terms
- hash — A short fixed-length fingerprint calculated from data, which changes completely if even one byte of the data changes.
- object ID — The hash that names a Git object, such as a commit, and that you type to refer to it.
- git cat-file — A low-level command that prints a Git object's type (-t), size (-s) or contents (-p) given its ID or another revision.
Taught in
- Why Version Control, And Why Git Won — Advanced Git Internals & Distributed Workflows
- What A Commit Really Is — Advanced Git Internals & Distributed Workflows