git hash-object

CommandNew filesChanged filesDeleted files
Alice/> git init
Initialized empty Git repository in /home/rene/github/github/git-internals/repos/hash-object/Alice/.git/
snap no: 1
Alice/> printf 'one foo
two bar
' > some-blob
snap no: 2

git hash-object with -w takes a file, computes the object id, and stores it in the .git directory

Alice/> git hash-object -w some-blob
9363c4e4606084a3c1fca83a3c535f65582ac834
snap no: 3

Use git cat-file -p to show the content of an object

Alice/> git cat-file -p 9363c4e4606084a3c1fca83a3c535f65582ac834
one foo
two bar
snap no: 4
Alice/> printf 'three baz
' >> some-blob
snap no: 5
Alice/> git hash-object -w some-blob
8db444301e5246a004784c9c7f39ab89725c3d2b
snap no: 6
Alice/> git cat-file -p 8db444301e5246a004784c9c7f39ab89725c3d2b
one foo
two bar
three baz
snap no: 7

cat-file with -t shows the object type rather than the object's content

Alice/> git cat-file -t 8db444301e5246a004784c9c7f39ab89725c3d2b
blob
snap no: 8