Objects and hashes
A file's name in git is the hash of what is inside it.
Git stores four kinds of object, and every one of them is named by a SHA-1 of its own contents. A blob is a file's bytes. A tree is a directory listing. A commit is a snapshot plus who made it and what came before. That is the whole storage model.
Because the name is derived from the contents, identical content is stored once and the same file always has the same id in every repository on earth. Nothing is ever edited in place — a change writes a new object and leaves the old one alone, which is what makes almost everything in git recoverable.
`git hash-object` shows you the id a file would get. With `-w` it writes the object too, without touching the index or the history.
Commands in this lesson
git hash-object- Show the object id a file's contents would get, and with -w store it
git cat-file- Print an object's type, size or contents exactly as stored